This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Purpose use the config to set the property "enable_dask" to avoid having to pass it as args to various functions and avoid inconsistencies. ## Code Changes * Get the property enable_dask via the config. * Hide dask behind a tasking module, so that dask is not a dependency of any of the products. This way we adopt a task parallel model that can be configure with any tasking runtime system.
- Loading branch information
Showing
3 changed files
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,18 @@ | ||
"""functionality for tasking and parallel computing.""" | ||
# Third-party | ||
import dask | ||
|
||
# First-party | ||
import idpi.config | ||
|
||
|
||
def delayed(fn): | ||
return dask.delayed(fn, pure=True) if idpi.config.get("enable_dask", False) else fn | ||
|
||
|
||
def compute(*delayed_objs): | ||
return ( | ||
dask.compute(*delayed_objs) | ||
if idpi.config.get("enable_dask", False) | ||
else delayed_objs | ||
) |