Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions simpeg_drivers-assets/uijson/plate_sweep.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@
"workdir": {
"main": true,
"group": "Base",
"label": "Working directory",
"fileDescription": [
"Directory"
],
"fileType": [
"directory"
],
"label": "Output directory",
"directoryOnly": true,
"enabled": true,
"value": ""
"enabled": false,
"optional": true,
"tootip": "Directory to store simulation results, relative to the working geoh5.",
"value": "./simulations"
},
"background_start": {
"main": true,
Expand Down
4 changes: 3 additions & 1 deletion simpeg_drivers/components/factories/misfit_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def assemble_arguments( # pylint: disable=arguments-differ
use_futures = self.client

# Pickle the simulation to the temporary file
with open(self.params.workpath / "simulation.pkl", mode="wb") as temp_file:
with open(
self.params.workpath / (self.params.geoh5.h5file.stem + ".pkl"), mode="wb"
) as temp_file:
pickle.dump(self.simulation, temp_file)

misfits = []
Expand Down
12 changes: 7 additions & 5 deletions simpeg_drivers/plate_simulation/sweep/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run(self):

@staticmethod
def run_trial(
data: dict, h5file: Path, workdir: Path | None, worker: tuple[str] | None = None
data: dict, h5file: Path, workdir: str, worker: tuple[str] | None = None
):
"""
Run a single trial of the plate simulation with name encoding from the parameters.
Expand All @@ -159,10 +159,12 @@ def run_trial(
json_string = dict_to_json_str(data)
uid = uuid_from_values(json_string)

if workdir is None:
workdir = h5file.parent
workerdir = h5file.parent / workdir

workerfile = workdir / f"{uid}.geoh5"
if not workerdir.exists():
workerdir.mkdir(exist_ok=True)

workerfile = workerdir / f"{uid}.geoh5"
if workerfile.exists():
logger.info("Skipping trial %s, since the file already exists.", uid)
return
Expand Down Expand Up @@ -197,7 +199,7 @@ def run_trial(
def run_block(
trials: list[dict],
h5file: Path,
workdir: Path | None,
workdir: str,
worker: tuple[str] | None = None,
):
"""
Expand Down
11 changes: 1 addition & 10 deletions simpeg_drivers/plate_simulation/sweep/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SweepOptions(Options):
inversion_type: str = "plate sweep"
template: SimPEGGroup | UIJsonGroup
sweeps: list[ParamSweep]
workdir: Path | None = None
workdir: str = "./simulations"

@field_serializer("sweeps")
def sweeps_to_params(self, sweeps):
Expand Down Expand Up @@ -105,16 +105,7 @@ def collect_sweep(param: str) -> dict:
}

sweep_params = [k.removesuffix("_start") for k in options if "_start" in k]

options["sweeps"] = [collect_sweep(param) for param in sweep_params]
workdir = options["workdir"]
if isinstance(workdir, str):
options["workdir"] = Path(workdir)
if isinstance(workdir, list):
if len(workdir) == 0:
options["workdir"] = None
else:
options["workdir"] = Path(workdir[0])

return options

Expand Down
6 changes: 2 additions & 4 deletions simpeg_drivers/plate_simulation/sweep/uijson.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# '
# '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

from geoh5py import Workspace
from geoh5py.shared.utils import fetch_active_workspace
from geoh5py.ui_json.forms import FileForm, FloatForm, GroupForm, IntegerForm
from geoh5py.ui_json.forms import FloatForm, GroupForm, IntegerForm, StringForm
from geoh5py.ui_json.ui_json import BaseUIJson
from pydantic import ConfigDict

Expand Down Expand Up @@ -44,4 +42,4 @@ class PlateSweepUIJson(BaseUIJson):
dip_stop: FloatForm
dip_count: IntegerForm
out_group: GroupForm | None
workdir: FileForm | None
workdir: StringForm | None