pybiolib 0.2.951__py3-none-any.whl → 1.2.1890__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- biolib/__init__.py +357 -11
- biolib/_data_record/data_record.py +380 -0
- biolib/_index/__init__.py +0 -0
- biolib/_index/index.py +55 -0
- biolib/_index/query_result.py +103 -0
- biolib/_internal/__init__.py +0 -0
- biolib/_internal/add_copilot_prompts.py +58 -0
- biolib/_internal/add_gui_files.py +81 -0
- biolib/_internal/data_record/__init__.py +1 -0
- biolib/_internal/data_record/data_record.py +85 -0
- biolib/_internal/data_record/push_data.py +116 -0
- biolib/_internal/data_record/remote_storage_endpoint.py +43 -0
- biolib/_internal/errors.py +5 -0
- biolib/_internal/file_utils.py +125 -0
- biolib/_internal/fuse_mount/__init__.py +1 -0
- biolib/_internal/fuse_mount/experiment_fuse_mount.py +209 -0
- biolib/_internal/http_client.py +159 -0
- biolib/_internal/lfs/__init__.py +1 -0
- biolib/_internal/lfs/cache.py +51 -0
- biolib/_internal/libs/__init__.py +1 -0
- biolib/_internal/libs/fusepy/__init__.py +1257 -0
- biolib/_internal/push_application.py +488 -0
- biolib/_internal/runtime.py +22 -0
- biolib/_internal/string_utils.py +13 -0
- biolib/_internal/templates/__init__.py +1 -0
- biolib/_internal/templates/copilot_template/.github/instructions/general-app-knowledge.instructions.md +10 -0
- biolib/_internal/templates/copilot_template/.github/instructions/style-general.instructions.md +20 -0
- biolib/_internal/templates/copilot_template/.github/instructions/style-python.instructions.md +16 -0
- biolib/_internal/templates/copilot_template/.github/instructions/style-react-ts.instructions.md +47 -0
- biolib/_internal/templates/copilot_template/.github/prompts/biolib_app_inputs.prompt.md +11 -0
- biolib/_internal/templates/copilot_template/.github/prompts/biolib_onboard_repo.prompt.md +19 -0
- biolib/_internal/templates/copilot_template/.github/prompts/biolib_run_apps.prompt.md +12 -0
- biolib/_internal/templates/dashboard_template/.biolib/config.yml +5 -0
- biolib/_internal/templates/github_workflow_template/.github/workflows/biolib.yml +21 -0
- biolib/_internal/templates/gitignore_template/.gitignore +10 -0
- biolib/_internal/templates/gui_template/.yarnrc.yml +1 -0
- biolib/_internal/templates/gui_template/App.tsx +53 -0
- biolib/_internal/templates/gui_template/Dockerfile +27 -0
- biolib/_internal/templates/gui_template/biolib-sdk.ts +82 -0
- biolib/_internal/templates/gui_template/dev-data/output.json +7 -0
- biolib/_internal/templates/gui_template/index.css +5 -0
- biolib/_internal/templates/gui_template/index.html +13 -0
- biolib/_internal/templates/gui_template/index.tsx +10 -0
- biolib/_internal/templates/gui_template/package.json +27 -0
- biolib/_internal/templates/gui_template/tsconfig.json +24 -0
- biolib/_internal/templates/gui_template/vite-plugin-dev-data.ts +50 -0
- biolib/_internal/templates/gui_template/vite.config.mts +10 -0
- biolib/_internal/templates/init_template/.biolib/config.yml +19 -0
- biolib/_internal/templates/init_template/Dockerfile +14 -0
- biolib/_internal/templates/init_template/requirements.txt +1 -0
- biolib/_internal/templates/init_template/run.py +12 -0
- biolib/_internal/templates/init_template/run.sh +4 -0
- biolib/_internal/templates/templates.py +25 -0
- biolib/_internal/tree_utils.py +106 -0
- biolib/_internal/utils/__init__.py +65 -0
- biolib/_internal/utils/auth.py +46 -0
- biolib/_internal/utils/job_url.py +33 -0
- biolib/_internal/utils/multinode.py +263 -0
- biolib/_runtime/runtime.py +157 -0
- biolib/_session/session.py +44 -0
- biolib/_shared/__init__.py +0 -0
- biolib/_shared/types/__init__.py +74 -0
- biolib/_shared/types/account.py +12 -0
- biolib/_shared/types/account_member.py +8 -0
- biolib/_shared/types/app.py +9 -0
- biolib/_shared/types/data_record.py +40 -0
- biolib/_shared/types/experiment.py +32 -0
- biolib/_shared/types/file_node.py +17 -0
- biolib/_shared/types/push.py +6 -0
- biolib/_shared/types/resource.py +37 -0
- biolib/_shared/types/resource_deploy_key.py +11 -0
- biolib/_shared/types/resource_permission.py +14 -0
- biolib/_shared/types/resource_version.py +19 -0
- biolib/_shared/types/result.py +14 -0
- biolib/_shared/types/typing.py +10 -0
- biolib/_shared/types/user.py +19 -0
- biolib/_shared/utils/__init__.py +7 -0
- biolib/_shared/utils/resource_uri.py +75 -0
- biolib/api/__init__.py +6 -0
- biolib/api/client.py +168 -0
- biolib/app/app.py +252 -49
- biolib/app/search_apps.py +45 -0
- biolib/biolib_api_client/api_client.py +126 -31
- biolib/biolib_api_client/app_types.py +24 -4
- biolib/biolib_api_client/auth.py +31 -8
- biolib/biolib_api_client/biolib_app_api.py +147 -52
- biolib/biolib_api_client/biolib_job_api.py +161 -141
- biolib/biolib_api_client/job_types.py +21 -5
- biolib/biolib_api_client/lfs_types.py +7 -23
- biolib/biolib_api_client/user_state.py +56 -0
- biolib/biolib_binary_format/__init__.py +1 -4
- biolib/biolib_binary_format/file_in_container.py +105 -0
- biolib/biolib_binary_format/module_input.py +24 -7
- biolib/biolib_binary_format/module_output_v2.py +149 -0
- biolib/biolib_binary_format/remote_endpoints.py +34 -0
- biolib/biolib_binary_format/remote_stream_seeker.py +59 -0
- biolib/biolib_binary_format/saved_job.py +3 -2
- biolib/biolib_binary_format/{attestation_document.py → stdout_and_stderr.py} +8 -8
- biolib/biolib_binary_format/system_status_update.py +3 -2
- biolib/biolib_binary_format/utils.py +175 -0
- biolib/biolib_docker_client/__init__.py +11 -2
- biolib/biolib_errors.py +36 -0
- biolib/biolib_logging.py +27 -10
- biolib/cli/__init__.py +38 -0
- biolib/cli/auth.py +46 -0
- biolib/cli/data_record.py +164 -0
- biolib/cli/index.py +32 -0
- biolib/cli/init.py +421 -0
- biolib/cli/lfs.py +101 -0
- biolib/cli/push.py +50 -0
- biolib/cli/run.py +63 -0
- biolib/cli/runtime.py +14 -0
- biolib/cli/sdk.py +16 -0
- biolib/cli/start.py +56 -0
- biolib/compute_node/cloud_utils/cloud_utils.py +110 -161
- biolib/compute_node/job_worker/cache_state.py +66 -88
- biolib/compute_node/job_worker/cache_types.py +1 -6
- biolib/compute_node/job_worker/docker_image_cache.py +112 -37
- biolib/compute_node/job_worker/executors/__init__.py +0 -3
- biolib/compute_node/job_worker/executors/docker_executor.py +532 -199
- biolib/compute_node/job_worker/executors/docker_types.py +9 -1
- biolib/compute_node/job_worker/executors/types.py +19 -9
- biolib/compute_node/job_worker/job_legacy_input_wait_timeout_thread.py +30 -0
- biolib/compute_node/job_worker/job_max_runtime_timer_thread.py +3 -5
- biolib/compute_node/job_worker/job_storage.py +108 -0
- biolib/compute_node/job_worker/job_worker.py +397 -212
- biolib/compute_node/job_worker/large_file_system.py +87 -38
- biolib/compute_node/job_worker/network_alloc.py +99 -0
- biolib/compute_node/job_worker/network_buffer.py +240 -0
- biolib/compute_node/job_worker/utilization_reporter_thread.py +197 -0
- biolib/compute_node/job_worker/utils.py +9 -24
- biolib/compute_node/remote_host_proxy.py +400 -98
- biolib/compute_node/utils.py +31 -9
- biolib/compute_node/webserver/compute_node_results_proxy.py +189 -0
- biolib/compute_node/webserver/proxy_utils.py +28 -0
- biolib/compute_node/webserver/webserver.py +130 -44
- biolib/compute_node/webserver/webserver_types.py +2 -6
- biolib/compute_node/webserver/webserver_utils.py +77 -12
- biolib/compute_node/webserver/worker_thread.py +183 -42
- biolib/experiments/__init__.py +0 -0
- biolib/experiments/experiment.py +356 -0
- biolib/jobs/__init__.py +1 -0
- biolib/jobs/job.py +741 -0
- biolib/jobs/job_result.py +185 -0
- biolib/jobs/types.py +50 -0
- biolib/py.typed +0 -0
- biolib/runtime/__init__.py +14 -0
- biolib/sdk/__init__.py +91 -0
- biolib/tables.py +34 -0
- biolib/typing_utils.py +2 -7
- biolib/user/__init__.py +1 -0
- biolib/user/sign_in.py +54 -0
- biolib/utils/__init__.py +162 -0
- biolib/utils/cache_state.py +94 -0
- biolib/utils/multipart_uploader.py +194 -0
- biolib/utils/seq_util.py +150 -0
- biolib/utils/zip/remote_zip.py +640 -0
- pybiolib-1.2.1890.dist-info/METADATA +41 -0
- pybiolib-1.2.1890.dist-info/RECORD +177 -0
- {pybiolib-0.2.951.dist-info → pybiolib-1.2.1890.dist-info}/WHEEL +1 -1
- pybiolib-1.2.1890.dist-info/entry_points.txt +2 -0
- README.md +0 -17
- biolib/app/app_result.py +0 -68
- biolib/app/utils.py +0 -62
- biolib/biolib-js/0-biolib.worker.js +0 -1
- biolib/biolib-js/1-biolib.worker.js +0 -1
- biolib/biolib-js/2-biolib.worker.js +0 -1
- biolib/biolib-js/3-biolib.worker.js +0 -1
- biolib/biolib-js/4-biolib.worker.js +0 -1
- biolib/biolib-js/5-biolib.worker.js +0 -1
- biolib/biolib-js/6-biolib.worker.js +0 -1
- biolib/biolib-js/index.html +0 -10
- biolib/biolib-js/main-biolib.js +0 -1
- biolib/biolib_api_client/biolib_account_api.py +0 -21
- biolib/biolib_api_client/biolib_large_file_system_api.py +0 -108
- biolib/biolib_binary_format/aes_encrypted_package.py +0 -42
- biolib/biolib_binary_format/module_output.py +0 -58
- biolib/biolib_binary_format/rsa_encrypted_aes_package.py +0 -57
- biolib/biolib_push.py +0 -114
- biolib/cli.py +0 -203
- biolib/cli_utils.py +0 -273
- biolib/compute_node/cloud_utils/enclave_parent_types.py +0 -7
- biolib/compute_node/enclave/__init__.py +0 -2
- biolib/compute_node/enclave/enclave_remote_hosts.py +0 -53
- biolib/compute_node/enclave/nitro_secure_module_utils.py +0 -64
- biolib/compute_node/job_worker/executors/base_executor.py +0 -18
- biolib/compute_node/job_worker/executors/pyppeteer_executor.py +0 -173
- biolib/compute_node/job_worker/executors/remote/__init__.py +0 -1
- biolib/compute_node/job_worker/executors/remote/nitro_enclave_utils.py +0 -81
- biolib/compute_node/job_worker/executors/remote/remote_executor.py +0 -51
- biolib/lfs.py +0 -196
- biolib/pyppeteer/.circleci/config.yml +0 -100
- biolib/pyppeteer/.coveragerc +0 -3
- biolib/pyppeteer/.gitignore +0 -89
- biolib/pyppeteer/.pre-commit-config.yaml +0 -28
- biolib/pyppeteer/CHANGES.md +0 -253
- biolib/pyppeteer/CONTRIBUTING.md +0 -26
- biolib/pyppeteer/LICENSE +0 -12
- biolib/pyppeteer/README.md +0 -137
- biolib/pyppeteer/docs/Makefile +0 -177
- biolib/pyppeteer/docs/_static/custom.css +0 -28
- biolib/pyppeteer/docs/_templates/layout.html +0 -10
- biolib/pyppeteer/docs/changes.md +0 -1
- biolib/pyppeteer/docs/conf.py +0 -299
- biolib/pyppeteer/docs/index.md +0 -21
- biolib/pyppeteer/docs/make.bat +0 -242
- biolib/pyppeteer/docs/reference.md +0 -211
- biolib/pyppeteer/docs/server.py +0 -60
- biolib/pyppeteer/poetry.lock +0 -1699
- biolib/pyppeteer/pyppeteer/__init__.py +0 -135
- biolib/pyppeteer/pyppeteer/accessibility.py +0 -286
- biolib/pyppeteer/pyppeteer/browser.py +0 -401
- biolib/pyppeteer/pyppeteer/browser_fetcher.py +0 -194
- biolib/pyppeteer/pyppeteer/command.py +0 -22
- biolib/pyppeteer/pyppeteer/connection/__init__.py +0 -242
- biolib/pyppeteer/pyppeteer/connection/cdpsession.py +0 -101
- biolib/pyppeteer/pyppeteer/coverage.py +0 -346
- biolib/pyppeteer/pyppeteer/device_descriptors.py +0 -787
- biolib/pyppeteer/pyppeteer/dialog.py +0 -79
- biolib/pyppeteer/pyppeteer/domworld.py +0 -597
- biolib/pyppeteer/pyppeteer/emulation_manager.py +0 -53
- biolib/pyppeteer/pyppeteer/errors.py +0 -48
- biolib/pyppeteer/pyppeteer/events.py +0 -63
- biolib/pyppeteer/pyppeteer/execution_context.py +0 -156
- biolib/pyppeteer/pyppeteer/frame/__init__.py +0 -299
- biolib/pyppeteer/pyppeteer/frame/frame_manager.py +0 -306
- biolib/pyppeteer/pyppeteer/helpers.py +0 -245
- biolib/pyppeteer/pyppeteer/input.py +0 -371
- biolib/pyppeteer/pyppeteer/jshandle.py +0 -598
- biolib/pyppeteer/pyppeteer/launcher.py +0 -683
- biolib/pyppeteer/pyppeteer/lifecycle_watcher.py +0 -169
- biolib/pyppeteer/pyppeteer/models/__init__.py +0 -103
- biolib/pyppeteer/pyppeteer/models/_protocol.py +0 -12460
- biolib/pyppeteer/pyppeteer/multimap.py +0 -82
- biolib/pyppeteer/pyppeteer/network_manager.py +0 -678
- biolib/pyppeteer/pyppeteer/options.py +0 -8
- biolib/pyppeteer/pyppeteer/page.py +0 -1728
- biolib/pyppeteer/pyppeteer/pipe_transport.py +0 -59
- biolib/pyppeteer/pyppeteer/target.py +0 -147
- biolib/pyppeteer/pyppeteer/task_queue.py +0 -24
- biolib/pyppeteer/pyppeteer/timeout_settings.py +0 -36
- biolib/pyppeteer/pyppeteer/tracing.py +0 -93
- biolib/pyppeteer/pyppeteer/us_keyboard_layout.py +0 -305
- biolib/pyppeteer/pyppeteer/util.py +0 -18
- biolib/pyppeteer/pyppeteer/websocket_transport.py +0 -47
- biolib/pyppeteer/pyppeteer/worker.py +0 -101
- biolib/pyppeteer/pyproject.toml +0 -97
- biolib/pyppeteer/spell.txt +0 -137
- biolib/pyppeteer/tox.ini +0 -72
- biolib/pyppeteer/utils/generate_protocol_types.py +0 -603
- biolib/start_cli.py +0 -7
- biolib/utils.py +0 -47
- biolib/validators/validate_app_version.py +0 -183
- biolib/validators/validate_argument.py +0 -134
- biolib/validators/validate_module.py +0 -323
- biolib/validators/validate_zip_file.py +0 -40
- biolib/validators/validator_utils.py +0 -103
- pybiolib-0.2.951.dist-info/LICENSE +0 -21
- pybiolib-0.2.951.dist-info/METADATA +0 -61
- pybiolib-0.2.951.dist-info/RECORD +0 -153
- pybiolib-0.2.951.dist-info/entry_points.txt +0 -3
- /LICENSE → /pybiolib-1.2.1890.dist-info/licenses/LICENSE +0 -0
biolib/__init__.py
CHANGED
|
@@ -1,39 +1,385 @@
|
|
|
1
|
+
# ruff: noqa: I001
|
|
2
|
+
# Imports to hide
|
|
1
3
|
import os
|
|
4
|
+
from urllib.parse import urlparse as _urlparse
|
|
2
5
|
|
|
3
|
-
from biolib import typing_utils
|
|
6
|
+
from biolib import typing_utils as _typing_utils
|
|
4
7
|
from biolib.app import BioLibApp as _BioLibApp
|
|
5
|
-
from biolib.biolib_logging import logger as _logger
|
|
6
|
-
from biolib.biolib_api_client import BiolibApiClient as _BioLibApiClient
|
|
7
8
|
|
|
9
|
+
# TODO: Fix ignore of type
|
|
10
|
+
from biolib.app.search_apps import search_apps # type: ignore
|
|
11
|
+
from biolib.biolib_errors import BioLibError
|
|
12
|
+
from biolib.biolib_logging import logger as _logger, logger_no_user_data as _logger_no_user_data
|
|
13
|
+
from biolib.experiments.experiment import Experiment
|
|
14
|
+
from biolib.biolib_api_client import BiolibApiClient as _BioLibApiClient, App
|
|
15
|
+
from biolib.jobs.job import Result as _Result
|
|
16
|
+
from biolib import user as _user
|
|
17
|
+
from biolib.typing_utils import List, Optional, cast as _cast
|
|
18
|
+
from biolib._data_record.data_record import DataRecord as _DataRecord
|
|
19
|
+
from biolib._internal.utils.job_url import parse_result_id_or_url as _parse_result_id_or_url
|
|
20
|
+
|
|
21
|
+
import biolib.api
|
|
8
22
|
import biolib.app
|
|
9
23
|
import biolib.cli
|
|
24
|
+
import biolib.sdk
|
|
10
25
|
import biolib.utils
|
|
11
26
|
|
|
12
|
-
|
|
13
27
|
# ------------------------------------ Function definitions for public Python API ------------------------------------
|
|
14
28
|
|
|
29
|
+
|
|
15
30
|
def call_cli() -> None:
|
|
16
|
-
biolib.cli.
|
|
31
|
+
biolib.cli.cli()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load(uri: str, suppress_version_warning: bool = False) -> _BioLibApp:
|
|
35
|
+
r"""Load a BioLib application by its URI or website URL.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
uri (str): The URI or website URL of the application to load. Can be either:
|
|
39
|
+
- App URI (e.g., 'biolib/myapp:1.0.0')
|
|
40
|
+
- Website URL (e.g., 'https://biolib.com/biolib/myapp/')
|
|
41
|
+
suppress_version_warning (bool): If True, don't print a warning when no version is specified.
|
|
42
|
+
Defaults to False.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
BioLibApp: The loaded application object
|
|
46
|
+
|
|
47
|
+
Example::
|
|
48
|
+
|
|
49
|
+
>>> # Load by URI
|
|
50
|
+
>>> app = biolib.load('biolib/myapp:1.0.0')
|
|
51
|
+
>>> # Load by website URL
|
|
52
|
+
>>> app = biolib.load('https://biolib.com/biolib/myapp/')
|
|
53
|
+
>>> result = app.cli('--help')
|
|
54
|
+
"""
|
|
55
|
+
return _BioLibApp(uri, suppress_version_warning=suppress_version_warning)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def search(
|
|
59
|
+
search_query: Optional[str] = None,
|
|
60
|
+
team: Optional[str] = None,
|
|
61
|
+
count: int = 100,
|
|
62
|
+
) -> List[str]:
|
|
63
|
+
r"""Search for BioLib applications.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
search_query (str, optional): Search query string
|
|
67
|
+
team (str, optional): Filter by team name
|
|
68
|
+
count (int): Maximum number of results to return. Defaults to 100.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List[str]: List of application URIs matching the search criteria
|
|
72
|
+
|
|
73
|
+
Example::
|
|
74
|
+
|
|
75
|
+
>>> # Search all apps
|
|
76
|
+
>>> apps = biolib.search()
|
|
77
|
+
>>> # Search by query
|
|
78
|
+
>>> alignment_apps = biolib.search('alignment')
|
|
79
|
+
>>> # Search team's apps
|
|
80
|
+
>>> team_apps = biolib.search(team='myteam')
|
|
81
|
+
"""
|
|
82
|
+
apps: List[str] = search_apps(search_query, team, count)
|
|
83
|
+
return apps
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def get_job(job_id: str, job_token: Optional[str] = None) -> _Result:
|
|
87
|
+
r"""Get a job by its ID or full URL.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
job_id (str): The UUID of the job to retrieve, or a full URL to the job.
|
|
91
|
+
Can be either:
|
|
92
|
+
- Job UUID (e.g., 'abc123')
|
|
93
|
+
- Full URL (e.g., 'https://biolib.com/result/abc123/?token=xyz789')
|
|
94
|
+
- Full URL with token parameter (e.g., 'biolib.com/result/abc123/token=xyz789')
|
|
95
|
+
job_token (str, optional): Authentication token for accessing the job.
|
|
96
|
+
Only needed for jobs that aren't owned by the current user.
|
|
97
|
+
If the URL contains a token, this parameter is ignored.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Job: The job object
|
|
101
|
+
|
|
102
|
+
Example::
|
|
103
|
+
|
|
104
|
+
>>> # Get by UUID
|
|
105
|
+
>>> job = biolib.get_job('abc123')
|
|
106
|
+
>>> # Get with explicit token
|
|
107
|
+
>>> job = biolib.get_job('abc123', job_token='xyz789')
|
|
108
|
+
>>> # Get by full URL with token
|
|
109
|
+
>>> job = biolib.get_job('https://biolib.com/result/abc123/?token=xyz789')
|
|
110
|
+
>>> # Get by URL with inline token format
|
|
111
|
+
>>> job = biolib.get_job('biolib.com/result/abc123/token=xyz789')
|
|
112
|
+
"""
|
|
113
|
+
uuid, token = _parse_result_id_or_url(job_id, job_token)
|
|
114
|
+
return _Result.create_from_uuid(uuid=uuid, auth_token=token)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def get_result(result_id: str, result_token: Optional[str] = None) -> _Result:
|
|
118
|
+
r"""Get a result by its ID or full URL.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
result_id (str): The UUID of the result to retrieve, or a full URL to the result.
|
|
122
|
+
Can be either:
|
|
123
|
+
- Result UUID (e.g., 'abc123')
|
|
124
|
+
- Full URL (e.g., 'https://biolib.com/result/abc123/?token=xyz789')
|
|
125
|
+
- Full URL with token parameter (e.g., 'biolib.com/result/abc123/token=xyz789')
|
|
126
|
+
result_token (str, optional): Authentication token for accessing the result.
|
|
127
|
+
Only needed for results that aren't owned by the current user.
|
|
128
|
+
If the URL contains a token, this parameter is ignored.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Result: The result object
|
|
132
|
+
|
|
133
|
+
Example::
|
|
134
|
+
|
|
135
|
+
>>> # Get by UUID
|
|
136
|
+
>>> result = biolib.get_result('abc123')
|
|
137
|
+
>>> # Get with explicit token
|
|
138
|
+
>>> result = biolib.get_result('abc123', result_token='xyz789')
|
|
139
|
+
>>> # Get by full URL with token
|
|
140
|
+
>>> result = biolib.get_result('https://biolib.com/result/abc123/?token=xyz789')
|
|
141
|
+
>>> # Get by URL with inline token format
|
|
142
|
+
>>> result = biolib.get_result('biolib.com/result/abc123/token=xyz789')
|
|
143
|
+
"""
|
|
144
|
+
uuid, token = _parse_result_id_or_url(result_id, result_token)
|
|
145
|
+
return _Result.create_from_uuid(uuid=uuid, auth_token=token)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_data_record(uri: str) -> _DataRecord:
|
|
149
|
+
r"""Get a data record by its URI.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
uri (str): The URI of the data record to retrieve
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
DataRecord: The data record object
|
|
156
|
+
|
|
157
|
+
Example::
|
|
158
|
+
|
|
159
|
+
>>> record = biolib.get_data_record('biolib/data/sequences:1.0.0')
|
|
160
|
+
"""
|
|
161
|
+
return _DataRecord.get_by_uri(uri)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def fetch_jobs(count: int = 25, status: Optional[str] = None) -> List[_Result]:
|
|
165
|
+
r"""Fetch a list of jobs from the server.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
count (int): Maximum number of jobs to fetch. Defaults to 25.
|
|
169
|
+
status (str, optional): Filter jobs by status. One of:
|
|
170
|
+
'in_progress', 'completed', 'failed', 'cancelled'
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
List[Job]: List of job objects matching the criteria
|
|
174
|
+
|
|
175
|
+
Example::
|
|
176
|
+
|
|
177
|
+
>>> # Get last 10 completed jobs
|
|
178
|
+
>>> jobs = biolib.fetch_jobs(10, status='completed')
|
|
179
|
+
>>> # Get last 100 jobs of any status
|
|
180
|
+
>>> all_jobs = biolib.fetch_jobs(100)
|
|
181
|
+
"""
|
|
182
|
+
return _Result.fetch_jobs(count, status)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def fetch_data_records(uri: Optional[str] = None, count: Optional[int] = None) -> List[_DataRecord]:
|
|
186
|
+
r"""Fetch a list of data records from the server.
|
|
187
|
+
|
|
188
|
+
Args:
|
|
189
|
+
uri (str, optional): Filter records by URI prefix
|
|
190
|
+
count (int, optional): Maximum number of records to fetch
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
List[DataRecord]: List of data record objects matching the criteria
|
|
194
|
+
|
|
195
|
+
Example::
|
|
196
|
+
|
|
197
|
+
>>> # Get all records
|
|
198
|
+
>>> records = biolib.fetch_data_records()
|
|
199
|
+
>>> # Get records with URI prefix
|
|
200
|
+
>>> seq_records = biolib.fetch_data_records('biolib/data/sequences')
|
|
201
|
+
"""
|
|
202
|
+
return _DataRecord.fetch(uri, count)
|
|
203
|
+
|
|
17
204
|
|
|
205
|
+
def get_experiment(uri: Optional[str] = None, name: Optional[str] = None) -> Experiment:
|
|
206
|
+
r"""Get an experiment by its URI or name.
|
|
18
207
|
|
|
19
|
-
|
|
20
|
-
|
|
208
|
+
Args:
|
|
209
|
+
uri (str, optional): The URI of the experiment
|
|
210
|
+
name (str, optional): The name of the experiment
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
Experiment: The experiment object
|
|
214
|
+
|
|
215
|
+
Raises:
|
|
216
|
+
ValueError: If neither or both uri and name are provided
|
|
217
|
+
|
|
218
|
+
Example::
|
|
219
|
+
|
|
220
|
+
>>> # Get by URI
|
|
221
|
+
>>> exp = biolib.get_experiment(uri='biolib/experiments/analysis')
|
|
222
|
+
>>> # Get by name
|
|
223
|
+
>>> exp = biolib.get_experiment(name='sequence-analysis')
|
|
224
|
+
"""
|
|
225
|
+
if (not uri and not name) or (uri and name):
|
|
226
|
+
raise ValueError('Must provide either uri or name')
|
|
227
|
+
|
|
228
|
+
return Experiment.get_by_uri(uri=_cast(str, uri or name))
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def show_jobs(count: int = 25) -> None:
|
|
232
|
+
r"""Display a table of recent jobs.
|
|
233
|
+
|
|
234
|
+
Args:
|
|
235
|
+
count (int): Maximum number of jobs to display. Defaults to 25.
|
|
236
|
+
|
|
237
|
+
Example::
|
|
238
|
+
|
|
239
|
+
>>> biolib.show_jobs() # Show last 25 jobs
|
|
240
|
+
>>> biolib.show_jobs(100) # Show last 100 jobs
|
|
241
|
+
"""
|
|
242
|
+
_Result.show_jobs(count=count)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def show_experiments(count: int = 25) -> None:
|
|
246
|
+
r"""Display a table of experiments.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
count (int): Maximum number of experiments to display. Defaults to 25.
|
|
250
|
+
|
|
251
|
+
Example::
|
|
252
|
+
|
|
253
|
+
>>> biolib.show_experiments() # Show last 25 experiments
|
|
254
|
+
>>> biolib.show_experiments(100) # Show last 100 experiments
|
|
255
|
+
"""
|
|
256
|
+
Experiment.show_experiments(count=count)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def sign_in() -> None:
|
|
260
|
+
_user.sign_in()
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def sign_out() -> None:
|
|
264
|
+
_user.sign_out()
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def login() -> None:
|
|
268
|
+
r"""Alias for :func:`sign_in`.
|
|
269
|
+
|
|
270
|
+
Example::
|
|
271
|
+
|
|
272
|
+
>>> biolib.login() # Same as biolib.sign_in()
|
|
273
|
+
"""
|
|
274
|
+
sign_in()
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def logout() -> None:
|
|
278
|
+
r"""Alias for :func:`sign_out`.
|
|
279
|
+
|
|
280
|
+
Example::
|
|
281
|
+
|
|
282
|
+
>>> biolib.logout() # Same as biolib.sign_out()
|
|
283
|
+
"""
|
|
284
|
+
sign_out()
|
|
21
285
|
|
|
22
286
|
|
|
23
287
|
def set_api_base_url(api_base_url: str) -> None:
|
|
288
|
+
r"""Set the base URL for the BioLib API.
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
api_base_url (str): The base URL for the BioLib API
|
|
292
|
+
|
|
293
|
+
Example::
|
|
294
|
+
|
|
295
|
+
>>> biolib.set_api_base_url('https://biolib.com')
|
|
296
|
+
|
|
297
|
+
Note:
|
|
298
|
+
This will also update related configuration like site hostname
|
|
299
|
+
and environment flags.
|
|
300
|
+
"""
|
|
24
301
|
_BioLibApiClient.initialize(base_url=api_base_url)
|
|
302
|
+
biolib.utils.BIOLIB_BASE_URL = api_base_url
|
|
303
|
+
biolib.utils.BIOLIB_SITE_HOSTNAME = _urlparse(api_base_url).hostname
|
|
304
|
+
biolib.utils.BASE_URL_IS_PUBLIC_BIOLIB = api_base_url.endswith('biolib.com') or (
|
|
305
|
+
os.environ.get('BIOLIB_ENVIRONMENT_IS_PUBLIC_BIOLIB', '').upper() == 'TRUE'
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def set_base_url(base_url: str) -> None:
|
|
310
|
+
r"""Alias for :func:`set_api_base_url`.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
base_url (str): The base URL for the BioLib API
|
|
314
|
+
|
|
315
|
+
Example::
|
|
316
|
+
|
|
317
|
+
>>> biolib.set_base_url('https://biolib.com')
|
|
318
|
+
"""
|
|
319
|
+
return set_api_base_url(base_url)
|
|
25
320
|
|
|
26
321
|
|
|
27
322
|
def set_api_token(api_token: str) -> None:
|
|
28
|
-
|
|
323
|
+
r"""Sign in using an API token.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
api_token (str): The API token to authenticate with
|
|
327
|
+
|
|
328
|
+
Example::
|
|
329
|
+
|
|
330
|
+
>>> biolib.set_api_token('my-api-token')
|
|
331
|
+
# Signed in using API token
|
|
332
|
+
"""
|
|
333
|
+
api_client = _BioLibApiClient.get()
|
|
334
|
+
api_client.sign_in_with_api_token(api_token)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def set_log_level(level: _typing_utils.Union[str, int]) -> None:
|
|
338
|
+
r"""Set the logging level for BioLib.
|
|
29
339
|
|
|
340
|
+
Args:
|
|
341
|
+
level (Union[str, int]): The log level to use. Can be a string
|
|
342
|
+
('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL') or an integer
|
|
343
|
+
level from the logging module.
|
|
30
344
|
|
|
31
|
-
|
|
345
|
+
Example::
|
|
346
|
+
|
|
347
|
+
>>> biolib.set_log_level('DEBUG') # Enable debug logging
|
|
348
|
+
>>> biolib.set_log_level('WARNING') # Only show warnings and errors
|
|
349
|
+
"""
|
|
32
350
|
_logger.setLevel(level)
|
|
351
|
+
_logger_no_user_data.setLevel(level)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _configure_requests_certificates():
|
|
355
|
+
if os.getenv('REQUESTS_CA_BUNDLE'):
|
|
356
|
+
if not os.getenv('SSL_CERT_FILE'):
|
|
357
|
+
# set SSL_CERT_FILE to urllib use same certs
|
|
358
|
+
os.environ['SSL_CERT_FILE'] = os.getenv('REQUESTS_CA_BUNDLE')
|
|
359
|
+
return # don't change REQUESTS_CA_BUNDLE if manually configured
|
|
360
|
+
|
|
361
|
+
certs_to_check = [
|
|
362
|
+
'/etc/ssl/certs/ca-certificates.crt',
|
|
363
|
+
'/etc/pki/tls/certs/ca-bundle.crt',
|
|
364
|
+
'/etc/ssl/ca-bundle.pem',
|
|
365
|
+
'/etc/pki/tls/cacert.pem',
|
|
366
|
+
'/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem',
|
|
367
|
+
'/etc/ssl/cert.pem',
|
|
368
|
+
]
|
|
369
|
+
|
|
370
|
+
for cert in certs_to_check:
|
|
371
|
+
if os.path.exists(cert):
|
|
372
|
+
os.environ['REQUESTS_CA_BUNDLE'] = cert
|
|
373
|
+
if not os.getenv('SSL_CERT_FILE'):
|
|
374
|
+
os.environ['SSL_CERT_FILE'] = cert
|
|
375
|
+
return
|
|
33
376
|
|
|
34
377
|
|
|
35
378
|
# -------------------------------------------------- Configuration ---------------------------------------------------
|
|
36
379
|
__version__ = biolib.utils.BIOLIB_PACKAGE_VERSION
|
|
37
|
-
|
|
380
|
+
_DEFAULT_LOG_LEVEL = 'INFO' if biolib.utils.IS_RUNNING_IN_NOTEBOOK else 'WARNING'
|
|
381
|
+
_logger.configure(default_log_level=_DEFAULT_LOG_LEVEL)
|
|
382
|
+
_logger_no_user_data.configure(default_log_level=_DEFAULT_LOG_LEVEL)
|
|
383
|
+
_configure_requests_certificates()
|
|
38
384
|
|
|
39
|
-
set_api_base_url(
|
|
385
|
+
set_api_base_url(biolib.utils.load_base_url_from_env())
|