villaInventorySdk
full docs here https://thanakijwanavit.github.io/villa-inventory-sdk/
Install
pip install villaInventorySdk
How to use
Uploading a large amount of data
sample input
from 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 printDict
sampleInput = [
{ '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
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| iprcode | brcode | ib_cf_qty | new_ib_vs_stock_cv | |
|---|---|---|---|---|
| 0 | 0000009 | 1000 | 50 | 27 |
| 1 | 0000004 | 1000 | 35 | 33 |
| 2 | 0000003 | 1003 | 36 | 33 |
Upload data
init 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 ms
Update 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
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| iprcode | brcode | ib_cf_qty | new_ib_vs_stock_cv |
|---|
Query 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
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| iprcode | brcode | ib_cf_qty | new_ib_vs_stock_cv | |
|---|---|---|---|---|
| 0 | 4 | 1000 | 35 | 33 |
| 1 | 9 | 1000 | 95 | 95 |
| 2 | 12 | 1000 | 36 | 36 |
| 3 | 26 | 1000 | 28 | 28 |
| 4 | 28 | 1000 | 9 | 9 |
| ... | ... | ... | ... | ... |
| 81551 | 244818 | 1000 | 0 | 0 |
| 81552 | 244820 | 1000 | 0 | 0 |
| 81553 | 244822 | 1000 | 0 | 0 |
| 81554 | 244823 | 1000 | 0 | 0 |
| 81555 | 3 | 1003 | 36 | 33 |
81556 rows × 4 columns
sdk.querySingleProduct2()
succesfully get url, returning pandas
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| iprcode | brcode | ib_cf_qty | new_ib_vs_stock_cv |
|---|
Metadata
Release files for villaInventorySdk 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| villaInventorySdk-0.1.6.tar.gz | 16.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| villaInventorySdk-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.3 kB
Release files / villaInventorySdk-0.1.6.tar.gz
| Download URL | villaInventorySdk-0.1.6.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2353b2af2bfc5dbec1617e4ed63ec3b29f22ad69219e3cf9ee48d98401a9ff4
|
|
BLAKE2b-256 checksum How to use checksums |
a7d05894d28d4c66e74948f5eaee2b14fb92d7fecac1951187583de9433735c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
|
Release files / villaInventorySdk-0.1.6-py3-none-any.whl
| Download URL | villaInventorySdk-0.1.6-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f1a0fd754096389254588a33f0a925c72162ede906e9152df80adb6db9879b3
|
|
BLAKE2b-256 checksum How to use checksums |
a925a3f5b022b3ecd62e1d2aab73053184fadc09bccf6dcf842ce5900d6a9106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
|
Security for villaInventorySdk 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.