Python wrapper for Benchling API with common functions used at MGTX DSC
Project description
mgtx-benchling-wrapper
A wrapper of the Benchling API SDK with common functions and workflows used at MGTX DSC.
Installation 🚀
You can install this package using:
pip install mgtx-benchling-wrapper
Quickstart 🚩
After creating an app on your Benchling tenant, create a config.yaml file in your repo. The following is an example of the contents of a config.yaml
Note: You might want to keep the app client secret separated from your main code.
BenchlingCredentials:
benchling_url: 'https://mytenant.benchling.com'
benchling_access_token: 'https://mytenant.benchling.com/api/v2/token'
app_client_id: 'your-app-client-id'
app_client_secret: 'your-app-client-secret'
AssaySchema:
schema_id: "schema_api_id"
Project:
project_id: "project_api_id"
The following is an example of the use of the assay_results_ingestion workflow.
import yaml
from mgtx_benchling_wrapper import BenchlingContext
from mgtx_benchling_wrapper import BenchlingWrapperFacade
from mgtx_benchling_wrapper import AssayResultIngestionWorkflow
from mgtx_benchling_wrapper.utils.logger import get_logger
logger = get_logger(__name__,
file_log_level='DEBUG',
console_log_level='INFO', )
def config():
with open("tests/config/test_config.yml") as f:
return yaml.safe_load(f)
#create the benchling context
ctx = BenchlingContext(
base_url=config()['BenchlingCredentials']['benchling_url'],
client_id=config()['BenchlingCredentials']['app_client_id'],
client_secret=config()['BenchlingCredentials']['app_client_secret'],
token_url=config()['BenchlingCredentials']['benchling_access_token'],
)
#initialize the wrapper
wrapper = BenchlingWrapperFacade(ctx.benchling())
#retrieve assay_schema_id
schema_id = config()['AssaySchema']['schema_id']
#retrieve project_id
project_id = config()['Project']['project_id']
#initiate results ingestion workflow
results_ingestion = AssayResultIngestionWorkflow(wrapper)
#ingest results on benchling
list_missing_entities = results_ingestion.assay_results_ingestion_updated(
[dataframe_to_ingest],
schema_id,
project_id,
unique_identifiers =['assay_run_id', 'sample_id']
)
Another example is accessing a Benchling assay results schema metadata.
#run the following after initializing the wrapper
from mgtx_benchling_wrapper import SchemaHandler
schema_handler = SchemaHandler(wrapper)
schema_definition = schema_handler.build_schema_definition(schema_id, 'assay_results_schema')
Another example is using a method from the wrapper directly to build your own workflow.
#run the following after initializing the wrapper
list_custom_entities = wrapper.custom_entities.get_by_names(['your-entity-1', 'your-entity-2'])
for custom_entity in list_custom_entities:
name = wrapper.custom_entities.name()
print(f"the name of the custom entity {custom_entity} is {name}.")
To release and publish run the following on gitBash to initialize the GitHub Action for publishing the package.
git tag v0.1.#
git push origin v0.1.#
Project details
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 mgtx_benchling_wrapper-0.1.5.tar.gz.
File metadata
- Download URL: mgtx_benchling_wrapper-0.1.5.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b29af42db29b2e28b702a37a896addbe7653b7838707477a2bf2df5559be2e0b
|
|
| MD5 |
cff3e56a75c8df10e0f3ca9fc0327267
|
|
| BLAKE2b-256 |
5796b3481ae3d6e50d1c0a0dc23a8ff1298256bbd068709870cd62fbd7590299
|
Provenance
The following attestation bundles were made for mgtx_benchling_wrapper-0.1.5.tar.gz:
Publisher:
publish.yml on MGTX-Data-Science/mgtx-benchling-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgtx_benchling_wrapper-0.1.5.tar.gz -
Subject digest:
b29af42db29b2e28b702a37a896addbe7653b7838707477a2bf2df5559be2e0b - Sigstore transparency entry: 1361528997
- Sigstore integration time:
-
Permalink:
MGTX-Data-Science/mgtx-benchling-wrapper@29ada3c050911bba0fa334c5137687fd17219a3d -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MGTX-Data-Science
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@29ada3c050911bba0fa334c5137687fd17219a3d -
Trigger Event:
push
-
Statement type:
File details
Details for the file mgtx_benchling_wrapper-0.1.5-py3-none-any.whl.
File metadata
- Download URL: mgtx_benchling_wrapper-0.1.5-py3-none-any.whl
- Upload date:
- Size: 50.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7274ae40db8a66588851bd83b10f4b819a26fcc4fe3c6c7bbc06546b37409c3d
|
|
| MD5 |
68ff6d4ebfdaefd9ca8a5c9146eff8f3
|
|
| BLAKE2b-256 |
b653bc9e5cff921de81d4b9fd94e5661869bc6591885f5b5ce453aa9a05571f3
|
Provenance
The following attestation bundles were made for mgtx_benchling_wrapper-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on MGTX-Data-Science/mgtx-benchling-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgtx_benchling_wrapper-0.1.5-py3-none-any.whl -
Subject digest:
7274ae40db8a66588851bd83b10f4b819a26fcc4fe3c6c7bbc06546b37409c3d - Sigstore transparency entry: 1361528999
- Sigstore integration time:
-
Permalink:
MGTX-Data-Science/mgtx-benchling-wrapper@29ada3c050911bba0fa334c5137687fd17219a3d -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MGTX-Data-Science
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@29ada3c050911bba0fa334c5137687fd17219a3d -
Trigger Event:
push
-
Statement type: