Modzy Python SDK
Modzy's Python SDK queries models, submits inference jobs, and returns results directly to your editor.
The job lifecycle | API Keys | Samples | Documentation
Basic usage
Submit a job providing the model, version, and input file:
job = client.jobs.submit_files('ed542963de', '0.0.27', {'input.txt': './some-file.txt'})
Hold until the inference is complete and results become available:
result = client.results.block_until_complete(job, timeout=None)
Get the output results:
results_json = result.get_first_outputs()['results.json']
print(results_json)
Fetch errors
Errors may arise for different reasons. Fetch errors to know what is their cause and how to fix them.
| Error | Description |
|---|---|
NetworkError |
The SDK is unable to connect. |
ResponseError |
The API returned an error code. |
Timeout |
The model is not finished running before the timeout elapsed. |
ResultsError |
The model returns an error during the inference job. |
Submitting jobs: NetworkError, ResponseError
try:
job = client.jobs.submit_files('ed542963de', '0.0.27', {'input.txt': './some-file.txt'})
except error.NetworkError as ex:
print('Could not connect to the API:', ex)
raise
except error.ResponseError as ex:
print('We got an error response from the API:', ex)
raise
While the model completes inference:
NetworkError, ResponseError, Timeout
timeout = 600
try:
result = client.results.block_until_complete(job, timeout=timeout)
except error.Timeout as ex:
print('Job still not finished after %d seconds' % timeout)
raise
except error.NetworkError as ex:
print('Could not connect to the API:', ex)
raise
except error.ResponseError as ex:
print('We got an error response from the API:', ex)
raise
Retrieving results:
ResultsError
try:
outputs = result.get_first_outputs()
except error.ResultsError as ex:
print('the model returned an error:', ex)
raise
results_json = outputs['results.json']
print(results_json)
Features
Currently we support the following API routes:
| Feature | Code | Api route |
|---|---|---|
| Retrieve all models | client.models.get_all() | api/models |
| Retrieve some models | client.models.get_models() | api/models |
| Retrieve model details | client.models.get() | api/models/:model-id |
| Retrieve model by name | client.models.get_by_name() | api/models |
| Retrieve related models | client.models.get_related() | api/models/:model-id/related-models |
| Retrieve model versions | client.models.get_versions() | api/models/:model-id/versions |
| Retrieve model version details | client.models.get_version() | api/models/:model-id/versions/:version-id |
| Retrieve all tags | client.tags.get_all() | api/models/tags |
| Retrieve Tags and Models | client.tags.get_tags_and_models() | api/models/tags/:tag-id |
| Submit a Job (Single Text) | client.jobs.submit_text() | api/jobs |
| Submit a Job (Multiple Text) | client.jobs.submit_text_bulk() | api/jobs |
| Submit a Job (Single Embedded) | client.jobs.submit_bytes() | api/jobs |
| Submit a Job (Multiple Embedded) | client.jobs.submit_bytes_bulk() | api/jobs |
| Submit a Job (Single File) | client.jobs.submit_files() | api/jobs |
| Submit a Job (Multiple Files) | client.jobs.submit_files_bulk() | api/jobs |
| Submit a Job (Single AWS S3) | client.jobs.submit_aws_s3() | api/jobs |
| Submit a Job (Multiple AWS S3) | client.jobs.submit_aws_s3_bulk() | api/jobs |
| Submit a Job (JDBC) | client.jobs.submit_jdbc() | api/jobs |
| Cancel job | job.cancel() | api/jobs/:job-id |
| Hold until inference is complete | job.block_until_complete() | api/jobs |
| Get Job details | client.jobs.get() | api/jobs/:job-id |
| Retrieve results | job.get_result() | api/jobs/:job-id |
| Retrieve Job History | client.jobs.get_history() | api/jobs/history |
Metadata
Release files for modzy-sdk 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| modzy-sdk-0.5.2.tar.gz | 26.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modzy_sdk-0.5.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 49.8 kB
Release files / modzy-sdk-0.5.2.tar.gz
| Download URL | modzy-sdk-0.5.2.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ae809c3a839c9341e51a969b5d0ae01403b892c8cadfe47e9c1f5cf060932d9
|
|
BLAKE2b-256 checksum How to use checksums |
68e45655ca9e45094a48298dd23f5f5eb3bf5bc45d730a4ef718bc49bd65115c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3
|
Release files / modzy_sdk-0.5.2-py2.py3-none-any.whl
| Download URL | modzy_sdk-0.5.2-py2.py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
26cbee912d16a86c17e42852c7e57b1527d3aec5aa066aae79abdb293a55f277
|
|
BLAKE2b-256 checksum How to use checksums |
4854653ac204399be3883b71eb7a19e8e7346155414efe81b282904e17ace319
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3
|