Skip to content
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

feat(dask): add nthreads option to dask-worker command #636

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

Alputer
Copy link
Member

@Alputer Alputer commented Feb 18, 2025

Following the integration of Dask into REANA and discussions with several REANA users, we identified the need to make the number of threads configurable.

In this commit, we propagate the specified number of threads per worker or the default value to the dask-worker command.

Closes reanahub/reana#874

@Alputer Alputer requested a review from tiborsimko February 18, 2025 16:21
@Alputer Alputer self-assigned this Feb 18, 2025
@Alputer Alputer changed the title feat(dask): add nthreads option to dask-worker command (#636) feat(dask): add nthreads option to dask-worker command Feb 18, 2025
@@ -346,6 +346,11 @@ def _parse_interactive_sessions_environments(env_var):
)
"""Maximum memory for one Dask worker."""

REANA_DASK_CLUSTER_DEFAULT_SINGLE_WORKER_THREADS = int(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: ‏We may need to sanitize the inputs. E.g. I have passed a non-integer value:

    dask:
      image: docker.io/coffeateam/coffea-dask-cc7:0.7.22-py3.10-g7f049
      single_worker_number_of_threads: 4.5

and the workflow was accepted for execution. (Perhaps we could verify integer-ness of the value already in the client, as the first line of defense. But we should also be sanitising on the server-side as well.)

The pod was obviously not starting due to:

$ k logs reana-run-dask-916d3266-default-worker-aa138e6474-5dc87954ngqzx
Usage: dask-worker [OPTIONS] [SCHEDULER] [PRELOAD_ARGV]...
Try 'dask-worker --help' for help.

Error: Invalid value for '--nthreads': '4.5' is not a valid integer.

And the pod went into a crash loop:

$ k get pods | grep -E '(NAME|aa13)'
NAME                                                              READY   STATUS             RESTARTS        AGE
reana-run-dask-916d3266-default-worker-aa138e6474-5dc87954ngqzx   0/1     CrashLoopBackOff   5 (2m12s ago)   4m58s

And the user would see the workflow as running:

$ rcg list
NAME                            RUN_NUMBER   CREATED               STARTED               ENDED                 STATUS
threads-45                      1            2025-02-20T13:13:10   2025-02-20T13:13:22   -                     running

Dunno when it would eventually stop, but we should exit early in these error situations.

Can you please round to the nearest integer on the server-side? And, whilst fixing this concrete usage scenario, can you please check also similar bordeline situations when a user passes an invalid container image or an invalid memory value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a check in reana-commons to prevent users from providing non-integer values. Since the OpenAPI specification in reana_analysis_schema.json already allows validation through type and regex, and considering they are enough to cover the basic checks, I guess it is sufficient, and we may not need additional checks beyond the initial reana.yaml validation.

Alputer added a commit to Alputer/reana-workflow-controller that referenced this pull request Feb 20, 2025
Following the integration of Dask into REANA and discussions with
several REANA users, we identified the need to make the number of
threads configurable.

In this commit, we propagate the specified number of threads per
worker or the default value to the `dask-worker` command.

Closes reanahub/reana#874
@Alputer Alputer force-pushed the dask-num-of-threads branch from 2f28672 to 4a8b871 Compare February 20, 2025 14:43
Alputer added a commit to Alputer/reana-workflow-controller that referenced this pull request Feb 20, 2025
Following the integration of Dask into REANA and discussions with
several REANA users, we identified the need to make the number of
threads configurable.

In this commit, we propagate the specified number of threads per
worker or the default value to the `dask-worker` command.

Closes reanahub/reana#874
@Alputer Alputer force-pushed the dask-num-of-threads branch from 4a8b871 to 95eb563 Compare February 20, 2025 15:12
Alputer added a commit to Alputer/reana-workflow-controller that referenced this pull request Feb 20, 2025
Following the integration of Dask into REANA and discussions with
several REANA users, we identified the need to make the number of
threads configurable.

In this commit, we propagate the specified number of threads per
worker or the default value to the `dask-worker` command.

Closes reanahub/reana#874
@Alputer Alputer force-pushed the dask-num-of-threads branch from 95eb563 to 4395a3d Compare February 20, 2025 15:23
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.20%. Comparing base (e4a64d8) to head (eaf2b59).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #636      +/-   ##
==========================================
+ Coverage   73.16%   73.20%   +0.04%     
==========================================
  Files          17       17              
  Lines        1986     1989       +3     
==========================================
+ Hits         1453     1456       +3     
  Misses        533      533              
Files with missing lines Coverage Δ
reana_workflow_controller/config.py 94.51% <100.00%> (+0.06%) ⬆️
reana_workflow_controller/dask.py 56.09% <100.00%> (+0.17%) ⬆️
reana_workflow_controller/workflow_run_manager.py 80.16% <ø> (ø)

Following the integration of Dask into REANA and discussions with
several REANA users, we identified the need to make the number of
threads configurable.

In this commit, we propagate the specified number of threads per
worker or the default value to the `dask-worker` command.

Closes reanahub/reana#874
@Alputer Alputer force-pushed the dask-num-of-threads branch from 4395a3d to eaf2b59 Compare February 20, 2025 15:59
Copy link
Member

@tiborsimko tiborsimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely 👍

@tiborsimko tiborsimko merged commit eaf2b59 into reanahub:master Feb 20, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

dask: expose number_of_threads option for Dask workers in reana.yaml
2 participants