Tetrascience Python SDK
Project description
ts-sdk
Tetrascience Python SDK
Version
v2.7.0
Table of Contents
Install
pip3 install ts-sdk
Task Script
Config.json
Overview
All Task Scripts have a config.json file that describes:
- what
languagea Task Script is written in - the
functionsa Task Script has available for a Protocol to use - the
runnerType, an optional field that is only used when letting the artifact builder know a Windows script (identified by using the value “windows-script”) is being built - the
maxCountof container instances that will be used by the task - and an optional field describing the amount of memory a task will need,
memoryInMB
Allowed IDS
Within the functions object of the configuration, the optional field allowedIds describes the IDS types a Task Script can produce.
The allowedIds field is used by the Context API's context.write_file (when writing an IDS) and context.write_ids functions to validate that the ids parameter of either function is allowed before writing an IDS.
allowedIds can be used in the following ways:
-
A single object with three properties:
namespace,slug,version-
When a function only generates one kind of IDS
-
The
idsparameter of the context.write_file and context.write_ids functions are optional since there is only one value in theallowedIdsfield -
Example:
"functions": [ { "slug": "generates-ids", "function": "main.generate_ids", "allowedIds": { "namespace": "common", "slug": "my-ids", "version": "v1.0.0" } } ]
-
-
An array of those objects with the three properties:
namespace,slug,version-
When a function can generate multiple IDS types
-
The
idsparameter of the context.write_file and context.write_ids functions is required and will be validated against theallowedIdsto confirm the task script is allowed to write that IDS -
Example:
"functions": [ { "slug": "generates-ids", "function": "main.generate_ids", "allowedIds": [ { "namespace": "common", "slug": "my-ids", "version": "v1.0.0" }, { "namespace": "common", "slug": "my-ids", "version": "v1.1.0" }, { "namespace": "common", "slug": "my-other-ids", "version": "v1.0.0" } ] } ]
-
-
null-
When a function does not generate any IDS
-
Calls to context.write_file (when
file_categoryis “IDS”) and context.write_ids will raise an exception- When the
file_categoryparameter is not "IDS", then context.write_file is not writing an IDS and therefore will not raise an exception
- When the
-
Example:
"functions": [ { "slug": "generates-ids", "function": "main.generate_ids", "allowedIds": null } ]
-
-
allowedIdsnot defined- Any IDS JSON can be written via context.write_file or context.write_ids
- no allowed IDSs are specified, so no check is performed
- Any IDS JSON passed to the context.write_file or context.write_ids still has to pass validation against the IDS specified by the
idsparameter
- Any IDS JSON can be written via context.write_file or context.write_ids
Changelog
Show
v2.7.0
- Add prerelease support for context.get_ids(...) if pipeline has prereleases enabled
- Add testing support for
context.read_file(form="download")andcontext.read_file(form="file_obj")
v2.6.3
- Fix OOM error handling in Lambda task scripts
testingsubmodule: Files in Task Scripts should always return bytes, not strings
v2.6.2
- Enable passing
Authdirectly toTask - Add basic stub support to
context.run_cmdin testing mode - Add a pattern matching API to
Task().run() - Repair
get_idsandget_schema_artifactin secure mode
v2.6.1
- Fix ts-cfg.json api_url usage to remove trailing "/v1"
context.write_detached_filemissing ids parameter fix
v2.6.0
-
Add support for running Task Scripts locally
example
from ts_sdk.testing.models import * local_file = LocalFile(path='test-file.json') with Trigger(file=local_file) as trigger: result, error = Task(function='main').run({'hello': 'world'}) print(result) print(local_file.labels)
-
Add support for Schema Artifact integration in Task Scripts: introduced
get_schema_artifactand ArtifactUtilDict for handling Schema Artifacts. -
Improve logger to include
tsSdkVersionin each log entry (visible in debug mode).
v2.5.1
- Set
ts_user_ids3 file meta for new file in datalake
v2.5.0
- Adjust publish to support Codebuild build_id in response for all artifact types
v2.4.1
- pass source_name and source_id in
context.write_detached_file(default to pipeline name and id)
v2.4.0
- new
context.write_detached_fileto write workflow input independent file
v2.3.0
- Add
return_commandparameter tocontext.run_cmdandcontext.run_command(default:False) - When set toTrue, returns the entire command response object from TDP instead of just the response body. Default behavior continues to returncommand.responseBodyon success or raise an exception containingcommand.responseBodyon failure.
v2.2.4
- Remove trailing comma from JSON changed in v2.2.2
v2.2.3
- Restore the explicit signing version when generating a pre-signed URL
v2.2.2
- Move
allowedIdsin the task script config.json schema from the Config object to the Function object - Add the new
successWhenandonFailedfields to the protocol v3 json schema
v2.2.1
- Use timeout=300s for internal task endpoints
v2.2.0
- Refactoring to avoid duplications with artifact-builder (for task script lambda feature)
v2.1.3
- Update
context.validate_idsto validate IDS instances usingts-ids-validator:v1.1.0- Check that the instance is valid against the schema
- Check that the shape of
datacubes[*].measures[*].valuesmatchesdatacubes[*].dimensions[*].scale
- Update the cli's deprecation date
v2.1.2
- Add exponential backoff to the task script runner
v2.1.1
- Pass the current workflow id to the file info service when mutating labels
v2.1.0
- Update logic for
context.run_cmdmethod (also applied tocontext.run_command):- Implemented exponential backoff for polling the command service for command status
- Introduced an optional
initial_delay_secparameter for initial delayed polling - Reduced the minimum
ttl_secthreshold from 300 seconds to 60 seconds
- Adds an optional query argument to
context.search_eql
v2.0.2
- Update IDS artifact validation: now when using
ts-sdk putto upload an IDS artifact, breaking change validation runs by downloading and comparing the previous version of the IDS from the Tetra Data Platform - see thets-ids-validatorpackage for more detail.
v2.0.1
- Pin
tenacitydependency to resolve compatibility issue with latest version
v2.0.0
- Secure mode + bug fixes
v1.4.2
- upgrade
smart_open(v4.2.0→v6.3.0)
v1.4.1
- Make
allowedIDSnon-mandatory for task-script, to maintain backward compatibility
v1.4.0
- Added functionality to support
allowedIdsfeature
v1.3.10
- Internal fixes (
/update-statusAPI call retry)
v1.3.9
CLI Improvements
- Make artifact build failure more evident to the user
ts-sdk putwill check forrequirements.txtfile before uploading
Context Function Improvements
- Add support to
write_fileto receive a dictionary instead of only strings - Validate dictionary inputs to
write_fileagainst IDS - Enforce IDS input to
write_idsmust be a dictionary - Validate length of the name and value of labels
- Validate labels more thoroughly, in more places
- Add a new DataClass for better label definition
Other
- All code formatted with
black - Adjust abstract dependencies in
setup.pyto be less strict so that it will work better within task scripts - Replace
jsonlibrary withsimplejsonfor speed and usability
v1.3.8
- Internal fixes (secrets handling)
v1.3.7
- Add
--exclude-foldersargument tots-sdk put task-scriptthat excludes common folders that generally do not need to be part of the uploaded task script (e.g..git,example-input,__tests__) - Add local check to prevent uploading artifacts using
ts-sdk putthat would be rejected by the server for being too large - Improve error messages for adding invalid labels to files
v1.3.6
- Add new s3 meta:
- DO_NOT_INHERIT_LABELS
- CONTENT_CREATED_FROM_FILE_ID
v1.3.5
- Fix bug where datalake file_key was incorrectly generated
v1.3.2
- Update
context.write_file()to validate file upload path - Fix logging issues
- Improve namespace validation
- Update
printfunctionality to be more accurate and group arguments to the same call together
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ts_sdk-2.7.0.tar.gz.
File metadata
- Download URL: ts_sdk-2.7.0.tar.gz
- Upload date:
- Size: 71.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf972e244e253ab12979f161c5d1c83156c4dcf3aeb99766ef4ac7e1bbe121c
|
|
| MD5 |
0c5830efbd76be7601729a7ede85b8a0
|
|
| BLAKE2b-256 |
33ffb1f256b9a16f2aaab5ec9471812cecc629697cef1de21b1cd1ec8e9ff0cd
|
File details
Details for the file ts_sdk-2.7.0-py3-none-any.whl.
File metadata
- Download URL: ts_sdk-2.7.0-py3-none-any.whl
- Upload date:
- Size: 101.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f80d12a4b9cd0257d35089ed70abfa597027457009f4097d935d83e00eed0247
|
|
| MD5 |
a969d4cbf3e889c5b7658b79193ef4f8
|
|
| BLAKE2b-256 |
522b2b1b9f7acbea4a8d4aaeac4a30cc6525688850d999bade2afcceaffdc8f8
|