Skip to content

Commit

Permalink
use libE_specs option, calc_dir_id_width
Browse files Browse the repository at this point in the history
  • Loading branch information
jlnav committed Aug 9, 2023
1 parent 4f25c0d commit dd77ce5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/data_structures/libE_specs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ the ``LibeSpecs`` class. When provided as a Python class, options are validated
Whether to allow overwrites and access to previous ensemble and workflow directories in subsequent runs.
``False`` by default to protect results.

"calc_dir_id_width" [int] = ``4``:
The width of the ID component of a calculation directory name. Up to this many additional
zeros are padded to the sim/gen ID.

"use_worker_dirs" [bool] = ``False``:
Whether to organize calculation directories under worker-specific directories:

Expand Down
1 change: 0 additions & 1 deletion libensemble/libE.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def libE(
exit_criteria = ensemble.exit_criteria.dict(by_alias=True, exclude_none=True)
alloc_specs = ensemble.alloc_specs.dict(by_alias=True)
libE_specs = ensemble.libE_specs.dict(by_alias=True)
libE_specs["_exit_criteria"] = exit_criteria # otherwise the workers don't have exit_criteria

# Extract platform info from settings or environment
platform_info = get_platform(libE_specs)
Expand Down
14 changes: 10 additions & 4 deletions libensemble/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SimSpecs(BaseModel):
persis_in: Optional[List[str]] = []
"""
List of field names that will be passed to a persistent simulation function
throughout runtime, following initialization
throughout runtime, following initialization.
"""

# list of tuples for dtype construction
Expand All @@ -65,20 +65,20 @@ class SimSpecs(BaseModel):
List of tuples corresponding to NumPy dtypes. e.g. ``("dim", int, (3,))``, or ``("path", str)``.
Typically used to initialize an output array within the simulation function:
``out = np.zeros(100, dtype=sim_specs["out"])``.
Also used to construct the complete dtype for libEnsemble's history array
Also necessary to construct the complete dtype for libEnsemble's history array.
"""

globus_compute_endpoint: Optional[str] = ""
"""
A Globus Compute (https://www.globus.org/compute) ID corresponding to an active endpoint on a remote system.
libEnsemble's workers will submit simulator function instances to this endpoint to be executed, instead of
calling them locally
calling them locally.
"""

user: Optional[dict] = {}
"""
A user-data dictionary to place bounds, constants, settings, or other parameters for customizing
the simulator function
the simulator function.
"""

@validator("out", pre=True)
Expand Down Expand Up @@ -325,6 +325,12 @@ class LibeSpecs(BaseModel):
If not using calculation directories, contents are copied to the ensemble directory
"""

calc_dir_id_width: Optional[int] = 4
"""
The width of the ID component of a calculation directory name. Up to this many additional
zeros are padded to the sim/gen ID.
"""

platform: Optional[str] = ""
"""Name of a known platform defined in the platforms module.
Expand Down
3 changes: 1 addition & 2 deletions libensemble/utils/output_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def __init__(self, libE_specs: dict, loc_stack: Optional[LocationStack] = None):
if self.ensemble_copy_back:
self.copybackdir = self.workflow_dir / Path(self.ensemble_dir.stem + "_back")

ec = self.specs.get("_exit_criteria", {})
self.pad = len(str(ec.get("sim_max", ""))) or len(str(ec.get("gen_max", "")))
self.pad = self.specs.get("calc_dir_id_width", 4)

def make_copyback(self) -> None:
"""Check for existing ensemble dir and copybackdir, make copyback if doesn't exist"""
Expand Down

0 comments on commit dd77ce5

Please sign in to comment.