Closed
Conversation
aldbr
reviewed
Nov 26, 2025
diracx-api/src/diracx/api/jobs.py
Outdated
| sandboxes_pfn = await create_sandbox( | ||
| paths=[Path(file_path) for file_path in isb] | ||
| ) | ||
| print(f"InputSandbox created: {sandboxes_pfn[13:]}") |
Contributor
There was a problem hiding this comment.
Same here. We should use:
logging.infoinstead ofprint- or an optional callback function as a parameter of
submit_jobs.
Option1 is probably best in this context.
Option2 could be interesting if we would want to have a progress bar for each processed job for instance (could be implemented later).
Contributor
Author
There was a problem hiding this comment.
Would something like this be ok for option2?:
In CLI:
@app.async_command()
async def submit(jdls: list[FileText]):
jdls_values = [jdl.read() for jdl in jdls]
jobs = await submit_jobs(jdls_values, print_callback=print)
print(
f"--- Inserted {len(jobs)} jobs with ids: {', '.join(map(str, (job.job_id for job in jobs)))}"
)In API:
@with_client
async def submit_jobs(jdls: list[str], *, client: AsyncDiracClient, print_callback=None):
# Create and upload InputSandboxes from JDLs
for i, jdl in enumerate(jdls):
if print_callback:
print_callback(f"--- Processing job {i + 1}/{len(jdls)}...")
...
if class_ad_job.lookupAttribute("InputSandbox"):
...
isb_log=f"InputSandbox created for job {i + 1}/{len(jdls)}: {sandboxes_pfn[13:]}\n"
logging.info(isb_log)
if print_callback:
print_callback(isb_log)
...
jobs = await client.jobs.submit_jdl_jobs(list(jdls))
return jobsWhich would return:
> dirac jobs submit test.jdl test2.jdl
--- Processing job 1/2...
InputSandbox created for job 1/2: /S3/demo-sandboxes/diracAdmin/admin/admin/sha256:d264668aeb631a84cb5d5ac1e5c01b1fa361923eb60b1209c9d833abcf0a5c6c.tar.zst
--- Processing job 2/2...
InputSandbox created for job 2/2: /S3/demo-sandboxes/diracAdmin/admin/admin/sha256:984bc7b95829313ca5a5df126662485fe510f2ae4bde648d996777dad055efd4.tar.zst
--- Inserted 2 jobs with ids: 1, 2
Contributor
|
@Stellatsuu I am closing your PR because we will assign input sandboxes to jobs in a different way and we need to have |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to: #13, #619
cc: @natthan-pigoux
Changes:
InputSandbox = {PFN}, it replaces the previous local file./api/jobs/{job_id}/sandbox/outputto/api/jobs/{job_id}/sandbox/{sandbox_type}Testing:
Example of JDL
job.jdl:Submitting the job using the
CLI:dirac jobs submit job.jdlExample of return values:
Assigning the InputSB to the job: