Skip to content

Commit cf15da6

Browse files
committed
BREAKING CHANGE: Taking only output file name as (mandatory) input argument. params and stuff handled via the tools function make_param_string.
1 parent 53425d9 commit cf15da6

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

simmanager/simmanager.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ class SimManager:
5353
:param sim_name: Simulation Name
5454
:param root_dir: Root directory containing results. See point 1. above for more
5555
details
56+
:param output_dir_name: string containing the name of the output
57+
directory. If specified, param_dict and suffix are ignored.
5658
:param param_dict: Dictionary in the form of ``dict(paramname1=param1val, paramname2=param2val)``.
5759
See point 1. above to see it's usage in creating the output directory.
5860
Default is an empty dictionary.
59-
:param suffix: Suffix used for various output files. This is passed on as an
61+
:param file_suffix: Suffix used for various output files. This is passed on as an
6062
argument in the creation of the contained Paths object
6163
:param write_protect_dirs: Enable/Disable write protecting the directories
6264
:param tee_stdx_to: Give file name here to tee the output to the provided file name.
@@ -68,25 +70,26 @@ class SimManager:
6870
from the EDITOR environment variable. It defaults to vim.
6971
"""
7072

71-
def __init__(self, sim_name, root_dir, param_dict={}, suffix="", write_protect_dirs=True, tee_stdx_to=None, open_desc_for_edit=False):
73+
def __init__(self, sim_name, root_dir, output_dir_name, *, file_suffix="", write_protect_dirs=True, tee_stdx_to=None, open_desc_for_edit=False):
7274

7375
self._sim_name = sim_name
7476
self._root_dir = root_dir
7577
if not os.path.exists(root_dir):
7678
raise SimManagerError("The root directory {} does not exist. Please create it.".format(root_dir))
77-
self._suffix = suffix
78-
self._param_combo = order_dict_alphabetically(param_dict)
79+
self._output_dir_name = output_dir_name
80+
self._file_suffix = file_suffix
81+
7982
self._write_protect_dirs = write_protect_dirs
8083
self.tee_stdx_to = tee_stdx_to
8184
self.open_desc_for_edit = open_desc_for_edit
8285
self.stdout_redirected_obj = None
8386

8487
def __enter__(self):
8588
output_dir_path = self._aquire_output_dir()
86-
self._paths = Paths(output_dir_path, suffix=self._suffix)
89+
self._paths = Paths(output_dir_path, suffix=self._file_suffix)
8790
try:
8891
self._store_sim_reproduction_data()
89-
except SimMetadataManagerError as E:
92+
except SimMetadataManagerError:
9093
_rm_anything_recursive(output_dir_path)
9194
raise
9295
try:
@@ -118,11 +121,7 @@ def _aquire_output_dir(self):
118121
in it. If directory already exists, raise a :class:`PathsError`
119122
complaining about this.
120123
"""
121-
param_string = make_param_string(**self._param_combo)
122-
if param_string == "":
123-
output_dir_path = os.path.join(self._root_dir, self._sim_name)
124-
else:
125-
output_dir_path = os.path.join(self._root_dir, self._sim_name, param_string)
124+
output_dir_path = os.path.join(self._root_dir, self._sim_name, self._output_dir_name)
126125
try:
127126
os.makedirs(output_dir_path)
128127
except OSError:

0 commit comments

Comments
 (0)