-
Notifications
You must be signed in to change notification settings - Fork 3
feat: replace plugin system with commands and dirac:Job hint #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ryuwd
wants to merge
3
commits into
DIRACGrid:main
Choose a base branch
from
ryuwd:feat/cwl-job-submission
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # Design: Input Sandbox via Replica Map | ||
|
|
||
| ## Context | ||
|
|
||
| The `dirac:Job` hint declares input sandbox files via `input_sandbox` source references: | ||
|
|
||
| ```yaml | ||
| hints: | ||
| - class: dirac:Job | ||
| input_sandbox: | ||
| - source: helper_script | ||
| - source: config_files | ||
| path: "conf/" | ||
| ``` | ||
|
|
||
| These reference CWL inputs whose values are files that need to be available on the worker node. The sandbox store handles upload/download of tar archives. | ||
|
|
||
| ## Design | ||
|
|
||
| ### Client Side (before submission) | ||
|
|
||
| 1. User uploads sandbox files via the sandbox store API → receives a sandbox ID (e.g., `SB:SandboxSE|/S3/diracx-sandbox-store/sha256:abc123.tar.zst`) | ||
| 2. User references the sandbox in their input YAML using a `SB:` prefixed path: | ||
|
|
||
| ```yaml | ||
| # input.yaml | ||
| helper_script: | ||
| class: File | ||
| path: "SB:SandboxSE|/S3/diracx-sandbox-store/sha256:abc123.tar.zst:helper.sh" | ||
|
|
||
| config_files: | ||
| - class: File | ||
| path: "SB:SandboxSE|/S3/diracx-sandbox-store/sha256:abc123.tar.zst:config/app.yaml" | ||
| - class: File | ||
| path: "SB:SandboxSE|/S3/diracx-sandbox-store/sha256:abc123.tar.zst:config/db.yaml" | ||
| ``` | ||
|
|
||
| The format is `SB:<sandbox_id>:<relative_path_inside_tar>`. | ||
|
|
||
| ### Submission (diracx-logic) | ||
|
|
||
| No changes needed. `submit_cwl_jobs` stores the input YAML as-is in `workflow_params`. The `SB:` paths are opaque strings at this stage. | ||
|
|
||
| ### Worker Side (JobWrapper) | ||
|
|
||
| Changes in `JobWrapper.__download_input_sandbox`: | ||
|
|
||
| 1. Iterate `input_sandbox` sources from the hint | ||
| 2. For each source, extract the CWL input value from `workflow_params` | ||
| 3. Detect `SB:` prefixed paths | ||
| 4. Parse the sandbox ID and relative path: `SB:<sandbox_id>:<relative_path>` | ||
| 5. Download the sandbox tar (once per unique sandbox ID — cache across sources) | ||
| 6. Extract to the job directory, respecting the hint's `path` field for subdirectory placement | ||
| 7. Add a replica map entry mapping the `SB:` path to the local extracted file path | ||
|
|
||
| ```python | ||
| # Pseudo-code for the worker-side resolution | ||
| for ref in job_hint.input_sandbox: | ||
| cwl_value = inputs.cwl.get(ref.source) | ||
| for file_path in extract_file_paths(cwl_value): | ||
| if file_path.startswith("SB:"): | ||
| sandbox_id, relative_path = parse_sb_path(file_path) | ||
|
|
||
| # Download + extract sandbox (cached per sandbox_id) | ||
| extract_dir = download_and_extract_sandbox(sandbox_id, job_path) | ||
|
|
||
| # Determine local path (respecting hint's path field) | ||
| dest_dir = job_path / ref.path if ref.path else job_path | ||
| local_path = dest_dir / relative_path | ||
|
|
||
| # Add to replica map for the executor | ||
| replica_map[file_path] = local_path | ||
| ``` | ||
|
|
||
| After this, the `DiracReplicaMapFsAccess` resolves `SB:` paths exactly like `LFN:` paths — the executor doesn't need to know the difference. | ||
|
|
||
| ### Replica Map as Universal Resolution Layer | ||
|
|
||
| With this design, the replica map resolves all file types uniformly: | ||
|
|
||
| | Prefix | Source | Resolution | | ||
| |--------|--------|------------| | ||
| | `LFN:` | Grid storage | `DataManager.getActiveReplicas()` → PFN URLs | | ||
| | `SB:` | Sandbox store | Download tar → extract → local file path | | ||
| | *(none)* | Local file | Direct path (already on worker) | | ||
|
|
||
| The CWL executor sees only local paths or URLs via the replica map — it never handles sandbox or grid storage directly. | ||
|
|
||
| ### Changes Required | ||
|
|
||
| | Location | Change | | ||
| |----------|--------| | ||
| | `JobWrapper.__download_input_sandbox` | Detect `SB:` paths, download/extract tar, add to replica map | | ||
| | `DiracReplicaMapFsAccess._resolve_lfn` | Handle `SB:` prefix in addition to `LFN:` (or rename to `_resolve_path`) | | ||
| | `JobWrapper.__build_replica_map` | Accept sandbox entries in addition to LFN entries | | ||
|
|
||
| ### Sandbox Caching | ||
|
|
||
| Multiple `input_sandbox` sources may reference the same sandbox tar (same `sandbox_id`, different `relative_path`). The download and extraction should happen once per unique sandbox ID: | ||
|
|
||
| ```python | ||
| extracted_sandboxes: dict[str, Path] = {} # sandbox_id → extracted directory | ||
|
|
||
| for sandbox_id in unique_sandbox_ids: | ||
| if sandbox_id not in extracted_sandboxes: | ||
| extracted_sandboxes[sandbox_id] = download_and_extract(sandbox_id, job_path) | ||
| ``` | ||
|
|
||
| ### Parametric Jobs | ||
|
|
||
| For parametric jobs (same CWL, different inputs), sandboxes may be shared: | ||
| - Same sandbox tar for all jobs → uploaded once by client, same `SB:` ID in all input YAMLs | ||
| - Different sandbox per job → different tars, different `SB:` IDs | ||
|
|
||
| The `workflows` table deduplication handles the CWL. The sandbox store handles file deduplication. `workflow_params` carries the per-job `SB:` references. | ||
|
|
||
| ### Open Questions | ||
|
|
||
| 1. **Sandbox path format** — is `SB:<sandbox_id>:<relative_path>` the right format, or should we use a different separator? The sandbox ID itself may contain colons. | ||
| 2. **Tar extraction** — does `download_sandbox` already extract, or do we need to handle `zstd` decompression + tar extraction ourselves? | ||
| 3. **Sandbox assignment** — does the sandbox need to be assigned to the job via `assign_sandbox_to_job` before the worker can download it? | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we shouldn't use the File
location:instead ofpath:to provide the sandbox url and keep path just with a local path.Since the CWL definition says
The location may refer to a local or remote resource;it seems closer to what is used here. What do you think?We could think of something similar for the input/output data as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! I am fixing it right now in DIRACGrid/diracx#877
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to leave comments on the PR DIRACGrid/diracx#877 as there you will find the most up to date implementation details