Package: villaInventorySdk
villaInventorySdkfull docs herehttps://thanakijwanavit.github.io/villa-inventory-sdk/Installpip install villaInventorySdkHow to useUploading a large amount of datasample inputfrom villaInventorySdk.inventory import InventorySdk
from random import randrange
import boto3, time, json
from dataclasses import dataclass
from dataclasses_json import dataclass_json
from datetime import datetime
import pandas as pd
from nicHelper.dictUtil import printDictsampleInput =  [ 
  { 'iprcode': '0000009', 'brcode': '1000', 'ib_cf_qty': '50', 'new_ib_vs_stock_cv': '27' },
  { 'iprcode': '0000004', 'brcode': '1000', 'ib_cf_qty': '35', 'new_ib_vs_stock_cv': '33' },
  { 'iprcode': '0000003', 'brcode': '1003', 'ib_cf_qty': '36', 'new_ib_vs_stock_cv': '33' }
    ]
df = pd.DataFrame(sampleInput)
df<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>iprcodebrcodeib_cf_qtynew_ib_vs_stock_cv000000091000502710000004100035332000000310033633Upload datainit sdk%%time
USER=None
PW = None
sdk = InventorySdk(user=USER, pw=PW, branchName = branch)CPU times: user 34.2 ms, sys: 7.54 ms, total: 41.8 ms
Wall time: 40.8 msUpdate inventory%%time
key = 'test'
r = sdk.uploadDf(df, key = key)
if r.status_code >= 400: raise Exception(r.json())
sdk.ingestData(key = key)signed url is 
url : https://in
fields
 key : test
 AWSAccessKeyId : ASIAVX4Z5T
 x-amz-security-token : IQoJb3JpZ2
 policy : eyJleHBpcm
 signature : apy2TqqnY2
CPU times: user 54.7 ms, sys: 12.3 ms, total: 67 ms
Wall time: 628 ms





{'body': '{"iprcode":{"0":"0000009","1":"0000004","2":"0000003"},"brcode":{"0":"1000","1":"1000","2":"1003"},"ib_cf_qty":{"0":"50","1":"35","2":"36"},"new_ib_vs_stock_cv":{"0":"27","1":"33","2":"33"}}',
 'statusCode': 200,
 'headers': {'Access-Control-Allow-Headers': '*',
  'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Methods': '*'}}test uploading full data#### test uploading real data 
# df = pd.read_csv('sampleData/inventory.csv', index_col=0, dtype=str).reset_index(drop=True)
# r = sdk.uploadDf(df, key = key)
# if r.status_code >= 400: raise Exception(r.json())
# sdk.ingestData(key = key)Query single product%%time
sdk.querySingleProduct2(iprcode='1234')succesfully get url, returning pandas
CPU times: user 103 ms, sys: 12.6 ms, total: 116 ms
Wall time: 799 ms<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>iprcodebrcodeib_cf_qtynew_ib_vs_stock_cvQuery Branch%%time
sdk.branchQuery(brcode='1000', iprcodes = [9])---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<timed eval> in <module>


~/SageMaker/.persisted_conda/python38/lib/python3.8/site-packages/nicHelper/wrappers.py in wrapper(self, *args, **kwargs)
     12         @wraps(func)
     13         def wrapper(self, *args, **kwargs):
---> 14             return func(self, *args, **kwargs)
     15         setattr(cls, func.__name__, wrapper)
     16         # Note we are not binding func, but wrapper which accepts self but does exactly the same as func


TypeError: branchQuery() got an unexpected keyword argument 'iprcodes'Query All%%time
sdk.queryAll2()succesfully get url, returning pandas
CPU times: user 76.2 ms, sys: 24.1 ms, total: 100 ms
Wall time: 673 ms<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>iprcodebrcodeib_cf_qtynew_ib_vs_stock_cv041000353319100095952121000363632610002828428100099...............815512448181000008155224482010000081553244822100000815542448231000008155531003363381556 rows × 4 columnssdk.querySingleProduct2()succesfully get url, returning pandas<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>iprcodebrcodeib_cf_qtynew_ib_vs_stock_cv