Skip to main content

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 villaPricingSdk.price import PricingSdk
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 =  [
               {
                  'cprcode': 9,
                  'brcode': 1000,
                  'price': 50
                },
               {
                  'cprcode': 4,
                  'brcode': 1000,
                  'price': 35
               },
                {
                  'cprcode': 3,
                  'brcode': 1003,
                  'price': 36,
               }
              ]
def getDf(input_:dict):
  return pd.DataFrame(input_)

df = getDf(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>
cprcode brcode price
0 9 1000 50
1 4 1000 35
2 3 1003 36

Upload data

init sdk

Update price

%%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://pr
fields
 key : test
 AWSAccessKeyId : ASIAVX4Z5T
 x-amz-security-token : IQoJb3JpZ2
 policy : eyJleHBpcm
 signature : kgDRy1etYA
CPU times: user 44.1 ms, sys: 4.2 ms, total: 48.3 ms
Wall time: 5.47 s





{'body': '{"cprcode":{"0":9,"1":4,"2":3},"brcode":{"0":1000,"1":1000,"2":1003},"price":{"0":50,"1":35,"2":36}}',
 'statusCode': 200,
 'headers': {'Access-Control-Allow-Headers': '*',
  'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Methods': '*'}}

Query single product

%%time
sdk.querySingleProduct2(cprcode=1234)
succesfully get url, returning pandas
CPU times: user 20.5 ms, sys: 0 ns, total: 20.5 ms
Wall time: 2.69 s
<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>
cprcode brcode price
4 1234.0 1000.0 123.0

Query Branch

%%time
sdk.branchQuery(1000)
---------------------------------------------------------------------------

KeyError                                  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


~/SageMaker/stacks/villaMaster/villa-master-dev/price/villa-price-sdk/villaPricingSdk/price.py in branchQuery(self, brcode, cprcodes)
    151   })
    152   rawReturn = lambda_.invoke(functionName=self.endpoint.queryBranch(), input = payload)
--> 153   parsedReturn = Response.parseBody(rawReturn)
    154   return pd.read_feather(parsedReturn['url'])
    155 


~/SageMaker/.persisted_conda/python38/lib/python3.8/site-packages/awsSchema/apigateway.py in parseBody(cls, dictInput)
     22   @classmethod
     23   def parseBody(cls, dictInput:dict):
---> 24     response = cls.fromDict(dictInput)
     25     return response.body
     26 


~/SageMaker/.persisted_conda/python38/lib/python3.8/site-packages/awsSchema/apigateway.py in fromDict(cls, dictInput)
     31       dictInput should follow apigateway proxy integration
     32     '''
---> 33     body = dictInput.pop('body')
     34     return cls(
     35       body = json.loads(body),


KeyError: 'body'

Query All

%%time
sdk.queryAll2()
succesfully get url, returning pandas
CPU times: user 17.1 ms, sys: 137 µs, total: 17.2 ms
Wall time: 221 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>
cprcode brcode price
0 10806.0 1010.0 513.0
1 89190.0 1028.0 869.0
2 41962.0 1021.0 920.0
3 88179.0 1004.0 725.0
4 1234.0 1000.0 123.0
5 12345.0 1000.0 345.0
6 19163.0 1027.0 745.0
7 55427.0 1022.0 561.0
8 35004.0 1002.0 625.0
9 4.0 1000.0 35.0
10 4.0 1000.0 35.0
11 4.0 1000.0 35.0
12 4.0 1000.0 35.0
13 9.0 1000.0 50.0
14 9.0 1000.0 50.0
15 9.0 1000.0 50.0
16 9.0 1000.0 50.0
17 23505.0 1000.0 187.0
18 3.0 1003.0 36.0
19 3.0 1003.0 36.0
20 71386.0 1017.0 470.0
21 69721.0 1006.0 843.0

Metadata

Release files for villaPricingSdk 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for villaPricingSdk 0.0.2
File Size Uploaded Provenance
villaPricingSdk-0.0.2.tar.gz 17.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for villaPricingSdk 0.0.2
File Interpreter ABI Platform
villaPricingSdk-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.9 kB

Release files / villaPricingSdk-0.0.2.tar.gz

Download URL villaPricingSdk-0.0.2.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
68e64da801e436bcffe7c652fbefadd3edd69f0123e7428839bb1894fdd9ca8d
BLAKE2b-256 checksum
How to use checksums
481226b1b07df44e55ad14a86448ca2e3cd3133c50f86d6a66effda20bb2aed2
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 / villaPricingSdk-0.0.2-py3-none-any.whl

Download URL villaPricingSdk-0.0.2-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46720bf13a5c4148e765ec6741eaa6094e47b3d8e218c2a98eb6dc27060cb6f6
BLAKE2b-256 checksum
How to use checksums
94779f3bbca75180049c15aaf4254b0116fb45df8f18e6c51a1fdf8366d95340
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 villaPricingSdk 0.0.2

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page