Package: ts-sdk
ts-sdkTetrascience Python SDKVersionv2.0.0Table of ContentsInstallUsageInit a new protocolUpload artifactIDS ValidationTask ScriptConfig.jsonOverviewAllowed IDSChangelogv1.4.0v1.3.10v1.3.9CLI ImprovementsContext Function ImprovementsOtherv1.3.8v1.3.7v1.3.6v1.3.5v1.3.2Installpip3 install ts-sdkUsageInit a new protocolts-sdkinit-o<org>-p<protocol-slug>-t<task-script-slug>-f<protocol-folder>cd<protocol-folder>/task-script
pipenvinstall--dev# task-script code modifications...pipenvrunpytestUpload artifactexportTS_ORG=<your-org-slug>exportTS_API_URL=https://api.tetrascience.com/v1exportTS_AUTH_TOKEN=<token>
ts-sdkput<ids|protocol|task-script><namespace><slug><version><artifact-folder>It's also possible to use the configuration JSON file (cfg.json):{"api_url":"https://api.tetrascience.com/v1","auth_token":"your-token","org":"your-org","ignore_ssl":false}Usage:ts-sdk put <ids|protocol|task-script> <namespace> <slug> <version> <artifact-folder> -c cfg.jsonIDS ValidationWhen uploading IDS artifact, validation will be performed usingts-ids-validatorpackage.
Validation failures for IDS will be printed on the console.Task ScriptConfig.jsonOverviewAll Task Scripts have aconfig.jsonfile that describes:whatlanguagea Task Script is written inthefunctionsa Task Script has available for a Protocol to usetherunnerType, 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 builtthemaxCountof container instances that will be used by the taskand an optional field describing the amount of memory a task will need,memoryInMBAllowed IDSWithin thefunctionsobject of the configuration, the optional fieldallowedIdsdescribes the IDS types a Task Script can produce.TheallowedIdsfield is used by the Context API'scontext.write_file(when writing an IDS) andcontext.write_idsfunctions to validate that the ids parameter of either function is allowed before writing an IDS.allowedIdscan be used in the following ways:A single object with three properties:namespace,slug,versionWhen a function only generates one kind of IDSTheidsparameter of thecontext.write_fileandcontext.write_idsfunctions are optional since there is only one value in theallowedIdsfieldExample:"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,versionWhen a function can generate multiple IDS typesTheidsparameter of thecontext.write_fileandcontext.write_idsfunctions is required and will be validated against theallowedIdsto confirm the task script is allowed to write that IDSExample:"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"}]}]nullWhen a function does not generate any IDSCalls tocontext.write_file(whenfile_categoryis “IDS”) andcontext.write_idswill raise an exceptionWhen thefile_categoryparameter is not "IDS", thencontext.write_fileis not writing an IDS and therefore will not raise an exceptionExample:"functions":[{"slug":"generates-ids","function":"main.generate_ids","allowedIds":null}]allowedIdsnot definedAny IDS JSON can be written viacontext.write_fileorcontext.write_idsno allowed IDSs are specified, so no check is performedAny IDS JSON passed to thecontext.write_fileorcontext.write_idsstill has to pass validation against the IDS specified by theidsparameterChangelogv2.0.0Secure mode + bug fixesv1.4.2upgradesmart_open(v4.2.0→v6.3.0)v1.4.1MakeallowedIDSnon-mandatory for task-script, to maintain backward compatibilityv1.4.0Added functionality to supportallowedIdsfeaturev1.3.10Internal fixes (/update-statusAPI call retry)v1.3.9CLI ImprovementsMake artifact build failure more evident to the userts-sdk putwill check forrequirements.txtfile before uploadingContext Function ImprovementsAdd support towrite_fileto receive a dictionary instead of only stringsValidate dictionary inputs towrite_fileagainst IDSEnforce IDS input towrite_idsmust be a dictionaryValidate length of the name and value of labelsValidate labels more thoroughly, in more placesAdd a new DataClass for better label definitionOtherAll code formatted withblackAdjust abstract dependencies insetup.pyto be less strict so that it will work better within task scriptsReplacejsonlibrary withsimplejsonfor speed and usabilityv1.3.8Internal fixes (secrets handling)v1.3.7Add--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 usingts-sdk putthat would be rejected by the server for being too largeImprove error messages for adding invalid labels to filesv1.3.6Add new s3 meta:DO_NOT_INHERIT_LABELSCONTENT_CREATED_FROM_FILE_IDv1.3.5Fix bug where datalake file_key was incorrectly generatedv1.3.2Updatecontext.write_file()to validate file upload pathFix logging issuesImprove namespace validationUpdateprintfunctionality to be more accurate and group arguments to the same call together