-
Notifications
You must be signed in to change notification settings - Fork 31
InputSB support #711
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
base: main
Are you sure you want to change the base?
InputSB support #711
Conversation
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:]}") |
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.
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).
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.
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
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: