dh-cli 0.17.5__tar.gz → 0.18.5__tar.gz
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.
- {dh_cli-0.17.5 → dh_cli-0.18.5}/PKG-INFO +2 -1
- {dh_cli-0.17.5 → dh_cli-0.18.5}/pyproject.toml +2 -1
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/__init__.py +2 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/aws_batch.py +18 -0
- dh_cli-0.18.5/src/dh_cli/batch/commands/finalize.py +335 -0
- dh_cli-0.17.5/src/dh_cli/batch/commands/finalize.py → dh_cli-0.18.5/src/dh_cli/batch/commands/finalize_pipelines.py +1 -293
- dh_cli-0.18.5/src/dh_cli/batch/commands/finalize_rfd4.py +43 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/retry.py +7 -1
- dh_cli-0.18.5/src/dh_cli/batch/commands/retry_rfd4.py +88 -0
- dh_cli-0.18.5/src/dh_cli/batch/commands/rfd4.py +206 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/engine_commands.py +2 -2
- dh_cli-0.18.5/tests/batch/fixtures/rfd4/5o45_cropped.cif.zst +0 -0
- dh_cli-0.18.5/tests/batch/rfd4_installed_check.py +121 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_aws_batch_resources.py +7 -0
- dh_cli-0.18.5/tests/batch/test_rfd4_path_regressions.py +98 -0
- dh_cli-0.18.5/tests/batch/test_rfd4_retry.py +225 -0
- dh_cli-0.18.5/tests/batch/test_rfd4_submit.py +350 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_submit_job_tags.py +7 -0
- dh_cli-0.18.5/tests/batch/test_terraform_revision.py +117 -0
- dh_cli-0.18.5/tests/engines_studios/test_launch_engine_types.py +66 -0
- dh_cli-0.18.5/tests/test_finalize_rfd4.py +198 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/.gitignore +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/LICENSE +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/README.md +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/_identity.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/boltz.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/cancel.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/clean.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/cost.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/disco.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/embed_esmc.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/embed_t5.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/equilibrator.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/esmfold2.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/list_jobs.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/local.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/logs.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/orca.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/protmpnn.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/protmpnn_to_boltz.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/rfd3.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/status.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/submit.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/commands/wait_for.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/cost_report.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/fasta_utils.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/h5_utils.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/job_id.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/manifest.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/batch/s3_transport.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/bedrock/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/bedrock/commands.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/bedrock/cost_report.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/bedrock/pricing.yaml +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/cloud_commands.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/codeartifact.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/api_client.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/auth.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/progress.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/retry.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/ssh_config.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/studio_commands.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/engines_studios/studio_resolve.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/github_commands.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/auth.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/deploy.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/local.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/mcp_catalogue.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/mcp_server.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/mcp_tools.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/test.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/tf.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/hz/users.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/main.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/sweep.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/src/dh_cli/warehouse.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/cur_fixtures.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_batch_cost_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_batch_cost_filters.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_batch_cost_reader.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_batch_cost_reconcile.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_batch_cost_report.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_image_override.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_import_without_pandas.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_no_train_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_submit_cpu_only.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_submit_image_validation.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_submit_merge.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/batch/test_submit_mlflow_env.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/conftest.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/A_cache_write.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/B_cache_read.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/C_plain.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/D_cursor_user.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/E_service_role.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/F_legacy_shared.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/fixtures/G_unknown_model.json +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_build_report.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_classify_arn.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_cli_exit_codes.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_cost_calc.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_cost_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_cur_reconciliation.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_key_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_render_formats.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_resolve_base_model.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_rotate.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/bedrock/test_s3_walker.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/test_engine_retry_commands.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/test_launch_gateway_timeout.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/test_retry.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/test_ssh_config.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/test_studio_resolution_commands.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/engines_studios/test_studio_resolve.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/__init__.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/conftest.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_engine_role_cannot_read_github_pat.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_identity.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_login.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_login_error_paths.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_login_security.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_logout.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_rotate.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/github/test_status.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/live_smoke.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/test_auth.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/test_init.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/test_mcp_catalogue.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/test_mcp_server.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/test_suites.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/hz/test_users.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_aws_status.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_cloud_gcp.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_disco_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_disco_jobdef.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_embed_esmc_cli.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_equilibrator_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_esmfold2_cli.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_boltz_tar.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_disco.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_disco_dispatch.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_equilibrator.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_esmfold2.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_protmpnn.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_finalize_rfd3.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_rfd3_command.py +0 -0
- {dh_cli-0.17.5 → dh_cli-0.18.5}/tests/test_sweep.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dh-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.5
|
|
4
4
|
Summary: Dayhoff Labs developer CLI
|
|
5
5
|
Author-email: Dayhoff Labs <dev@dayhofflabs.com>
|
|
6
6
|
License: # PolyForm Noncommercial License 1.0.0
|
|
@@ -126,6 +126,7 @@ License-File: LICENSE
|
|
|
126
126
|
Requires-Python: >=3.11
|
|
127
127
|
Requires-Dist: boto3>=1.36.0
|
|
128
128
|
Requires-Dist: click>=8.0.0
|
|
129
|
+
Requires-Dist: dh-batch[rfd4-config]==0.9.4
|
|
129
130
|
Requires-Dist: pyarrow>=15
|
|
130
131
|
Requires-Dist: pydantic>=2.0.0
|
|
131
132
|
Requires-Dist: pyyaml>=6.0
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dh-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.18.5"
|
|
8
8
|
description = "Dayhoff Labs developer CLI"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
readme = "README.md"
|
|
@@ -13,6 +13,7 @@ authors = [
|
|
|
13
13
|
{name = "Dayhoff Labs", email = "dev@dayhofflabs.com"},
|
|
14
14
|
]
|
|
15
15
|
dependencies = [
|
|
16
|
+
"dh-batch[rfd4-config]==0.9.4",
|
|
16
17
|
"boto3>=1.36.0",
|
|
17
18
|
"click>=8.0.0",
|
|
18
19
|
"pyarrow>=15",
|
|
@@ -28,6 +28,7 @@ from .commands.protmpnn import protmpnn
|
|
|
28
28
|
from .commands.protmpnn_to_boltz import protmpnn_to_boltz
|
|
29
29
|
from .commands.retry import retry
|
|
30
30
|
from .commands.rfd3 import rfd3
|
|
31
|
+
from .commands.rfd4 import rfd4
|
|
31
32
|
from .commands.status import status
|
|
32
33
|
from .commands.submit import submit
|
|
33
34
|
from .commands.wait_for import wait_for
|
|
@@ -116,6 +117,7 @@ batch_cli.add_command(protmpnn)
|
|
|
116
117
|
batch_cli.add_command(orca)
|
|
117
118
|
batch_cli.add_command(protmpnn_to_boltz, name="protmpnn-to-boltz")
|
|
118
119
|
batch_cli.add_command(rfd3)
|
|
120
|
+
batch_cli.add_command(rfd4)
|
|
119
121
|
batch_cli.add_command(disco)
|
|
120
122
|
|
|
121
123
|
__all__ = ["batch_cli"]
|
|
@@ -147,6 +147,8 @@ class BatchClient:
|
|
|
147
147
|
try:
|
|
148
148
|
if image_override:
|
|
149
149
|
job_definition = self._register_image_override(job_definition, image_override)
|
|
150
|
+
elif ":" not in job_definition:
|
|
151
|
+
job_definition = self._terraform_revision(job_definition)
|
|
150
152
|
|
|
151
153
|
submit_args: dict[str, Any] = {
|
|
152
154
|
"jobName": job_name,
|
|
@@ -207,6 +209,22 @@ class BatchClient:
|
|
|
207
209
|
except ClientError as e:
|
|
208
210
|
raise BatchError(f"Failed to submit job: {e}")
|
|
209
211
|
|
|
212
|
+
def _terraform_revision(self, definition_name: str) -> str:
|
|
213
|
+
"""ARN of the newest ACTIVE Terraform-managed revision of a definition.
|
|
214
|
+
|
|
215
|
+
An unversioned name resolves to the latest ACTIVE revision, which is
|
|
216
|
+
often an --image override registered by another user. Terraform
|
|
217
|
+
revisions carry the Terraform=true tag; override revisions never do,
|
|
218
|
+
because _register_image_override registers containerProperties only.
|
|
219
|
+
Keep it that way, or this resolver picks up overrides.
|
|
220
|
+
"""
|
|
221
|
+
paginator = self.batch.get_paginator("describe_job_definitions")
|
|
222
|
+
pages = paginator.paginate(jobDefinitionName=definition_name, status="ACTIVE")
|
|
223
|
+
managed = [d for page in pages for d in page["jobDefinitions"] if d.get("tags", {}).get("Terraform") == "true"]
|
|
224
|
+
if not managed:
|
|
225
|
+
raise BatchError(f"No ACTIVE Terraform-managed revision of job definition {definition_name}")
|
|
226
|
+
return max(managed, key=lambda d: d["revision"])["jobDefinitionArn"]
|
|
227
|
+
|
|
210
228
|
def _register_image_override(self, base_definition: str, image: str) -> str:
|
|
211
229
|
"""Register a new revision of a job definition with a custom image.
|
|
212
230
|
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"""Finalize command for combining results and cleaning up."""
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
import tarfile
|
|
5
|
+
import tempfile
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
from ..manifest import (
|
|
11
|
+
BATCH_JOBS_BASE,
|
|
12
|
+
JobStatus,
|
|
13
|
+
delete_job_directory,
|
|
14
|
+
get_job_dir,
|
|
15
|
+
load_manifest,
|
|
16
|
+
save_manifest,
|
|
17
|
+
save_manifest_s3,
|
|
18
|
+
)
|
|
19
|
+
from .finalize_pipelines import (
|
|
20
|
+
_finalize_boltz as _finalize_boltz,
|
|
21
|
+
)
|
|
22
|
+
from .finalize_pipelines import (
|
|
23
|
+
_finalize_disco as _finalize_disco,
|
|
24
|
+
)
|
|
25
|
+
from .finalize_pipelines import (
|
|
26
|
+
_finalize_embeddings as _finalize_embeddings,
|
|
27
|
+
)
|
|
28
|
+
from .finalize_pipelines import (
|
|
29
|
+
_finalize_equilibrator as _finalize_equilibrator,
|
|
30
|
+
)
|
|
31
|
+
from .finalize_pipelines import (
|
|
32
|
+
_finalize_esmfold2 as _finalize_esmfold2,
|
|
33
|
+
)
|
|
34
|
+
from .finalize_pipelines import (
|
|
35
|
+
_finalize_generic as _finalize_generic,
|
|
36
|
+
)
|
|
37
|
+
from .finalize_pipelines import (
|
|
38
|
+
_finalize_protmpnn as _finalize_protmpnn,
|
|
39
|
+
)
|
|
40
|
+
from .finalize_pipelines import (
|
|
41
|
+
_finalize_rfd3 as _finalize_rfd3,
|
|
42
|
+
)
|
|
43
|
+
from .finalize_rfd4 import _finalize_rfd4
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@click.command()
|
|
47
|
+
@click.argument("job_id")
|
|
48
|
+
@click.option(
|
|
49
|
+
"--output",
|
|
50
|
+
required=True,
|
|
51
|
+
type=click.Path(),
|
|
52
|
+
help="Output path for combined results",
|
|
53
|
+
)
|
|
54
|
+
@click.option("--force", is_flag=True, help="Finalize even if some chunks failed")
|
|
55
|
+
@click.option(
|
|
56
|
+
"--keep-intermediates",
|
|
57
|
+
is_flag=True,
|
|
58
|
+
help="Don't delete job directory after finalizing",
|
|
59
|
+
)
|
|
60
|
+
@click.option(
|
|
61
|
+
"--full-output",
|
|
62
|
+
is_flag=True,
|
|
63
|
+
help="For Boltz: copy entire output directory (default: only essential files)",
|
|
64
|
+
)
|
|
65
|
+
@click.option(
|
|
66
|
+
"--skip-dedup",
|
|
67
|
+
is_flag=True,
|
|
68
|
+
help="Skip deduplication step (use if input has no duplicates)",
|
|
69
|
+
)
|
|
70
|
+
@click.option("--base-path", default=BATCH_JOBS_BASE, help="Base path for job data")
|
|
71
|
+
def finalize(job_id, output, force, keep_intermediates, full_output, skip_dedup, base_path):
|
|
72
|
+
"""Combine results and clean up job intermediates.
|
|
73
|
+
|
|
74
|
+
For embedding jobs, combines H5 files into a single output file.
|
|
75
|
+
For Boltz jobs, extracts essential files (CIF structures and confidence JSON).
|
|
76
|
+
|
|
77
|
+
\b
|
|
78
|
+
Examples:
|
|
79
|
+
# Embedding job - combine H5 files
|
|
80
|
+
dh batch finalize dma-embed-20260109-a3f2 --output /primordial/embeddings.h5
|
|
81
|
+
|
|
82
|
+
# Skip deduplication (faster if input has no duplicates)
|
|
83
|
+
dh batch finalize dma-embed-20260109-a3f2 --output /primordial/embeddings.h5 --skip-dedup
|
|
84
|
+
|
|
85
|
+
# Boltz job - extract essential files only (default)
|
|
86
|
+
dh batch finalize dma-boltz-20260113-190a --output /primordial/structures/
|
|
87
|
+
|
|
88
|
+
# Boltz job - copy all output files
|
|
89
|
+
dh batch finalize dma-boltz-20260113-190a --output /primordial/structures/ --full-output
|
|
90
|
+
|
|
91
|
+
# Keep job directory after finalizing
|
|
92
|
+
dh batch finalize dma-embed-20260109-a3f2 --output /primordial/out.h5 --keep-intermediates
|
|
93
|
+
"""
|
|
94
|
+
# Load manifest
|
|
95
|
+
try:
|
|
96
|
+
manifest = load_manifest(job_id, base_path)
|
|
97
|
+
except FileNotFoundError:
|
|
98
|
+
click.echo(f"Job not found: {job_id}", err=True)
|
|
99
|
+
raise SystemExit(1)
|
|
100
|
+
|
|
101
|
+
# Check job status
|
|
102
|
+
if manifest.status == JobStatus.FINALIZED:
|
|
103
|
+
click.echo(f"Job {job_id} is already finalized.", err=True)
|
|
104
|
+
raise SystemExit(1)
|
|
105
|
+
|
|
106
|
+
is_s3 = manifest.storage_mode == "s3"
|
|
107
|
+
s3_temp_dir = None
|
|
108
|
+
job_dir = get_job_dir(job_id, base_path)
|
|
109
|
+
output_path = Path(output).resolve()
|
|
110
|
+
if manifest.pipeline == "rfd4" and output_path.is_relative_to(job_dir.resolve()):
|
|
111
|
+
raise click.ClickException("RFD4 output must be outside the job directory to survive cleanup.")
|
|
112
|
+
|
|
113
|
+
# For embed jobs: if output is an existing directory, append a filename
|
|
114
|
+
if manifest.pipeline in ("embed-t5", "embed", "embed-esmc") and output_path.is_dir():
|
|
115
|
+
output_path = output_path / f"{job_id}.h5"
|
|
116
|
+
click.echo(f"Output is a directory, writing to: {output_path}")
|
|
117
|
+
|
|
118
|
+
if is_s3:
|
|
119
|
+
from ..s3_transport import delete_prefix, download_directory
|
|
120
|
+
|
|
121
|
+
# Download outputs from S3 to a temp directory
|
|
122
|
+
s3_temp_dir = Path(tempfile.mkdtemp())
|
|
123
|
+
s3_output_prefix = f"{manifest.s3_prefix}output/"
|
|
124
|
+
click.echo("Downloading outputs from S3...")
|
|
125
|
+
if manifest.pipeline == "boltz":
|
|
126
|
+
_download_boltz_s3_output(s3_output_prefix, s3_temp_dir)
|
|
127
|
+
else:
|
|
128
|
+
download_directory(s3_output_prefix, s3_temp_dir)
|
|
129
|
+
output_dir = s3_temp_dir
|
|
130
|
+
else:
|
|
131
|
+
output_dir = job_dir / "output"
|
|
132
|
+
|
|
133
|
+
# Check completion status
|
|
134
|
+
incomplete = _check_completion(job_id, base_path, output_dir=output_dir)
|
|
135
|
+
if incomplete:
|
|
136
|
+
click.echo(f"Found {len(incomplete)} incomplete chunks: {incomplete[:10]}...")
|
|
137
|
+
if not force:
|
|
138
|
+
click.echo()
|
|
139
|
+
click.echo("Use --force to finalize anyway, or retry failed chunks:")
|
|
140
|
+
click.echo(f" dh batch retry {job_id}")
|
|
141
|
+
if s3_temp_dir:
|
|
142
|
+
shutil.rmtree(s3_temp_dir, ignore_errors=True)
|
|
143
|
+
raise SystemExit(1)
|
|
144
|
+
click.echo()
|
|
145
|
+
click.echo(click.style("Warning: Finalizing with incomplete chunks", fg="yellow"))
|
|
146
|
+
|
|
147
|
+
# Update status
|
|
148
|
+
manifest.status = JobStatus.FINALIZING
|
|
149
|
+
if is_s3:
|
|
150
|
+
save_manifest_s3(manifest)
|
|
151
|
+
else:
|
|
152
|
+
save_manifest(manifest, base_path)
|
|
153
|
+
|
|
154
|
+
# Finalize based on pipeline type
|
|
155
|
+
click.echo()
|
|
156
|
+
if manifest.pipeline in ("embed-t5", "embed", "embed-esmc"):
|
|
157
|
+
_finalize_embeddings(output_dir, output_path, skip_dedup=skip_dedup)
|
|
158
|
+
elif manifest.pipeline == "boltz":
|
|
159
|
+
# Check if S3 essential mode was used — output is already filtered
|
|
160
|
+
s3_essential = is_s3 and manifest.output and getattr(manifest.output, "output_mode", "full") == "essential"
|
|
161
|
+
if full_output and s3_essential:
|
|
162
|
+
click.echo(
|
|
163
|
+
click.style(
|
|
164
|
+
"Warning: Job was submitted without --full-output. "
|
|
165
|
+
"S3 output contains only essential files (CIF + confidence JSON). "
|
|
166
|
+
"Re-submit with --full-output to get all files.",
|
|
167
|
+
fg="yellow",
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
_finalize_boltz(output_dir, output_path, full_output=full_output)
|
|
171
|
+
elif manifest.pipeline == "protmpnn":
|
|
172
|
+
_finalize_protmpnn(output_dir, output_path)
|
|
173
|
+
elif manifest.pipeline == "rfd4":
|
|
174
|
+
_finalize_rfd4(output_dir, output_path)
|
|
175
|
+
elif manifest.pipeline == "rfd3":
|
|
176
|
+
_finalize_rfd3(output_dir, output_path)
|
|
177
|
+
elif manifest.pipeline == "esmfold2":
|
|
178
|
+
_finalize_esmfold2(output_dir, output_path)
|
|
179
|
+
elif manifest.pipeline == "disco":
|
|
180
|
+
_finalize_disco(output_dir, output_path)
|
|
181
|
+
elif manifest.pipeline == "equilibrator":
|
|
182
|
+
_finalize_equilibrator(output_dir, output_path, job_id=job_id)
|
|
183
|
+
else:
|
|
184
|
+
_finalize_generic(output_dir, output_path)
|
|
185
|
+
|
|
186
|
+
# Update manifest
|
|
187
|
+
manifest.status = JobStatus.FINALIZED
|
|
188
|
+
if manifest.output:
|
|
189
|
+
manifest.output.destination = str(output_path)
|
|
190
|
+
manifest.output.finalized = True
|
|
191
|
+
if is_s3:
|
|
192
|
+
save_manifest_s3(manifest)
|
|
193
|
+
else:
|
|
194
|
+
save_manifest(manifest, base_path)
|
|
195
|
+
|
|
196
|
+
click.echo()
|
|
197
|
+
click.echo(click.style(f"✓ Results saved to: {output_path}", fg="green"))
|
|
198
|
+
|
|
199
|
+
# Clean up
|
|
200
|
+
if s3_temp_dir:
|
|
201
|
+
shutil.rmtree(s3_temp_dir, ignore_errors=True)
|
|
202
|
+
|
|
203
|
+
if not keep_intermediates:
|
|
204
|
+
if is_s3:
|
|
205
|
+
click.echo(f"Cleaning up S3 data: {manifest.s3_prefix}")
|
|
206
|
+
delete_prefix(manifest.s3_prefix)
|
|
207
|
+
click.echo(click.style("✓ S3 job data deleted", fg="green"))
|
|
208
|
+
else:
|
|
209
|
+
click.echo(f"Cleaning up job directory: {job_dir}")
|
|
210
|
+
delete_job_directory(job_id, base_path)
|
|
211
|
+
click.echo(click.style("✓ Job directory deleted", fg="green"))
|
|
212
|
+
else:
|
|
213
|
+
if is_s3:
|
|
214
|
+
click.echo(f"S3 data preserved: {manifest.s3_prefix}")
|
|
215
|
+
else:
|
|
216
|
+
click.echo(f"Job directory preserved: {job_dir}")
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _download_boltz_s3_output(s3_output_prefix: str, local_dir: Path) -> None:
|
|
220
|
+
"""Download Boltz tar outputs from S3 and extract into local_dir.
|
|
221
|
+
|
|
222
|
+
Workers produce one `boltz_results_<name>.tar` per prediction plus
|
|
223
|
+
`boltz_*.done` marker objects. This helper downloads only those keys
|
|
224
|
+
(ignoring anything else under the prefix), extracts each tar in place,
|
|
225
|
+
and removes the tar file afterwards so the resulting layout matches
|
|
226
|
+
what `_finalize_boltz` expects on Primordial.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
s3_output_prefix: S3 URI prefix like s3://bucket/jobs/<id>/output/
|
|
230
|
+
local_dir: Local directory to extract into
|
|
231
|
+
"""
|
|
232
|
+
from ..s3_transport import _get_client, parse_s3_uri
|
|
233
|
+
|
|
234
|
+
bucket, prefix_key = parse_s3_uri(s3_output_prefix)
|
|
235
|
+
client = _get_client()
|
|
236
|
+
local_dir.mkdir(parents=True, exist_ok=True)
|
|
237
|
+
|
|
238
|
+
paginator = client.get_paginator("list_objects_v2")
|
|
239
|
+
tar_count = 0
|
|
240
|
+
done_count = 0
|
|
241
|
+
for page in paginator.paginate(Bucket=bucket, Prefix=prefix_key):
|
|
242
|
+
for obj in page.get("Contents", []):
|
|
243
|
+
key = obj["Key"]
|
|
244
|
+
relative = key[len(prefix_key) :]
|
|
245
|
+
if not relative:
|
|
246
|
+
continue
|
|
247
|
+
basename = Path(relative).name
|
|
248
|
+
if basename.startswith("boltz_results_") and basename.endswith(".tar"):
|
|
249
|
+
tar_path = local_dir / basename
|
|
250
|
+
client.download_file(bucket, key, str(tar_path))
|
|
251
|
+
try:
|
|
252
|
+
with tarfile.open(tar_path, mode="r") as tf:
|
|
253
|
+
tf.extractall(local_dir)
|
|
254
|
+
finally:
|
|
255
|
+
tar_path.unlink(missing_ok=True)
|
|
256
|
+
tar_count += 1
|
|
257
|
+
elif basename.startswith("boltz_") and basename.endswith(".done"):
|
|
258
|
+
done_path = local_dir / basename
|
|
259
|
+
client.download_file(bucket, key, str(done_path))
|
|
260
|
+
done_count += 1
|
|
261
|
+
|
|
262
|
+
click.echo(f" Downloaded {tar_count} prediction tars, {done_count} done markers")
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def _check_completion(job_id: str, base_path: str, output_dir: Path | None = None) -> list[int | str]:
|
|
266
|
+
"""Check which chunks are incomplete (no .done marker).
|
|
267
|
+
|
|
268
|
+
Handles both original chunks (chunk_000.fasta) and resliced chunks
|
|
269
|
+
(chunk_r1_000.fasta). For original chunks that were resliced in a retry,
|
|
270
|
+
checks if all resliced chunks completed.
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
job_id: Job ID
|
|
274
|
+
base_path: Base path for batch jobs
|
|
275
|
+
output_dir: Override output directory (used for S3 temp dir)
|
|
276
|
+
"""
|
|
277
|
+
job_dir = get_job_dir(job_id, base_path)
|
|
278
|
+
input_dir = job_dir / "input"
|
|
279
|
+
if output_dir is None:
|
|
280
|
+
output_dir = job_dir / "output"
|
|
281
|
+
|
|
282
|
+
if not input_dir.exists():
|
|
283
|
+
return []
|
|
284
|
+
|
|
285
|
+
# Load manifest to check for resliced retries
|
|
286
|
+
try:
|
|
287
|
+
manifest = load_manifest(job_id, base_path)
|
|
288
|
+
if manifest.pipeline == "rfd4":
|
|
289
|
+
from dh_batch.rfd4_config import load_run
|
|
290
|
+
|
|
291
|
+
return [
|
|
292
|
+
name
|
|
293
|
+
for name in load_run(input_dir)["configs"]
|
|
294
|
+
if not (output_dir / f"rfd4_config_{Path(name).stem}.done").is_file()
|
|
295
|
+
]
|
|
296
|
+
resliced_indices: set[int] = set()
|
|
297
|
+
reslice_info: dict[str, int] = {} # prefix -> expected count
|
|
298
|
+
|
|
299
|
+
for retry in manifest.retries:
|
|
300
|
+
if retry.reslice_prefix and retry.reslice_count:
|
|
301
|
+
resliced_indices.update(retry.indices)
|
|
302
|
+
reslice_info[retry.reslice_prefix] = retry.reslice_count
|
|
303
|
+
except FileNotFoundError:
|
|
304
|
+
resliced_indices = set()
|
|
305
|
+
reslice_info = {}
|
|
306
|
+
|
|
307
|
+
incomplete = []
|
|
308
|
+
|
|
309
|
+
# Check original chunks (chunk_000.fasta pattern)
|
|
310
|
+
for chunk_path in sorted(input_dir.glob("chunk_[0-9][0-9][0-9].fasta")):
|
|
311
|
+
idx_str = chunk_path.stem.split("_")[1]
|
|
312
|
+
idx = int(idx_str)
|
|
313
|
+
|
|
314
|
+
# Check for original done marker
|
|
315
|
+
done_marker = output_dir / f"embed_{idx:03d}.done"
|
|
316
|
+
if done_marker.exists():
|
|
317
|
+
continue
|
|
318
|
+
|
|
319
|
+
# Check if this chunk was resliced
|
|
320
|
+
if idx in resliced_indices:
|
|
321
|
+
# Find which retry covered this index and check if complete
|
|
322
|
+
is_covered = False
|
|
323
|
+
for retry in manifest.retries:
|
|
324
|
+
if retry.reslice_prefix and retry.reslice_count and idx in retry.indices:
|
|
325
|
+
# Check if all resliced chunks for this retry completed
|
|
326
|
+
done_count = len(list(output_dir.glob(f"embed_{retry.reslice_prefix}_*.done")))
|
|
327
|
+
if done_count >= retry.reslice_count:
|
|
328
|
+
is_covered = True
|
|
329
|
+
break
|
|
330
|
+
if is_covered:
|
|
331
|
+
continue
|
|
332
|
+
|
|
333
|
+
incomplete.append(idx)
|
|
334
|
+
|
|
335
|
+
return incomplete
|