Skip to content

Commit df66582

Browse files
Merge pull request #1015 from rfbgo/appcopy
rename application.copy to application.clone since it edits the copy
2 parents 5b352fb + edcde57 commit df66582

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

lib/ramble/ramble/application.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,28 +215,28 @@ def experiment_lock(self):
215215

216216
return self._exp_lock
217217

218-
def copy(self):
219-
"""Deep copy an application instance"""
220-
new_copy = type(self)(self._file_path)
221-
self.generated_experiments.append(new_copy)
218+
def clone(self):
219+
"""Deep clone an application instance"""
220+
new_clone = type(self)(self._file_path)
221+
self.generated_experiments.append(new_clone)
222222

223223
if self._env_variable_sets:
224-
new_copy.set_env_variable_sets(self._env_variable_sets.copy())
224+
new_clone.set_env_variable_sets(self._env_variable_sets.copy())
225225
if self.variables:
226-
new_copy.set_variables(self.variables.copy(), self.experiment_set)
226+
new_clone.set_variables(self.variables.copy(), self.experiment_set)
227227
if self.internals:
228-
new_copy.set_internals(self.internals.copy())
228+
new_clone.set_internals(self.internals.copy())
229229
if self._formatted_executables:
230-
new_copy.set_formatted_executables(self._formatted_executables.copy())
230+
new_clone.set_formatted_executables(self._formatted_executables.copy())
231231

232-
new_copy.keywords = ramble.keywords.keywords.copy()
233-
new_copy.set_template(False)
234-
new_copy.repeats.set_repeats(False, 0)
235-
new_copy.set_chained_experiments(None)
232+
new_clone.keywords = ramble.keywords.keywords.copy()
233+
new_clone.set_template(False)
234+
new_clone.repeats.set_repeats(False, 0)
235+
new_clone.set_chained_experiments(None)
236236
if self.variants:
237-
new_copy.set_variants(self.variants)
237+
new_clone.set_variants(self.variants)
238238

239-
return new_copy
239+
return new_clone
240240

241241
def is_actionable(self):
242242
"""Determine if an experiment should be actioned in pipelines
@@ -781,7 +781,7 @@ def create_experiment_chain(self, workspace):
781781
# of the experiment, so the base_inst command above
782782
# doesn't get an application instance.
783783
if base_inst:
784-
new_inst = base_inst.copy()
784+
new_inst = base_inst.clone()
785785

786786
if namespace.variables in cur_exp_def:
787787
for var, val in cur_exp_def[namespace.variables].items():

lib/ramble/ramble/experiment_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def _prepare_experiment(
296296
self.keywords.application_name, allow_passthrough=False
297297
)
298298

299-
app_inst = ramble.repository.get(final_app_name).copy()
299+
app_inst = ramble.repository.get(final_app_name).clone()
300300
app_inst.set_variables(variables, self)
301301
app_inst.set_variants(context.variants)
302302
app_inst.set_env_variable_sets(context.env_variables)

lib/ramble/ramble/test/application.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,47 +110,47 @@ def test_application_copy_is_deep(mutable_mock_apps_repo, app_name):
110110
src_inst.set_env_variable_sets(defined_env_vars)
111111
src_inst.set_internals(defined_internals)
112112

113-
copy_inst = src_inst.copy()
113+
clone_inst = src_inst.clone()
114114

115115
# Test variables
116116
for var, val in src_inst.variables.items():
117-
assert var in copy_inst.variables.keys()
118-
assert copy_inst.variables[var] == val
117+
assert var in clone_inst.variables.keys()
118+
assert clone_inst.variables[var] == val
119119

120120
# Test env-vars
121121
for var_set in src_inst._env_variable_sets.keys():
122-
assert var_set in copy_inst._env_variable_sets.keys()
122+
assert var_set in clone_inst._env_variable_sets.keys()
123123
# Test set sets
124124
if var_set == "set":
125125
for var, val in src_inst._env_variable_sets[var_set].items():
126-
assert var in copy_inst._env_variable_sets[var_set]
127-
assert copy_inst._env_variable_sets[var_set][var] == val
126+
assert var in clone_inst._env_variable_sets[var_set]
127+
assert clone_inst._env_variable_sets[var_set][var] == val
128128
elif var_set == "append" or var_set == "prepend":
129129
for idx, set_group in enumerate(src_inst._env_variable_sets[var_set]):
130130
if "var-separator" in set_group:
131-
assert "var-separator" in copy_inst._env_variable_sets[var_set][idx]
131+
assert "var-separator" in clone_inst._env_variable_sets[var_set][idx]
132132
assert (
133-
copy_inst._env_variable_sets[var_set][idx]["var-separator"]
133+
clone_inst._env_variable_sets[var_set][idx]["var-separator"]
134134
== set_group["var-separator"]
135135
)
136136
if "vars" in set_group:
137-
assert "vars" in copy_inst._env_variable_sets[var_set][idx]
137+
assert "vars" in clone_inst._env_variable_sets[var_set][idx]
138138
for var, val in set_group["vars"].items():
139-
assert var in copy_inst._env_variable_sets[var_set][idx]["vars"]
140-
assert copy_inst._env_variable_sets[var_set][idx]["vars"][var] == val
139+
assert var in clone_inst._env_variable_sets[var_set][idx]["vars"]
140+
assert clone_inst._env_variable_sets[var_set][idx]["vars"][var] == val
141141
elif var_set == "unset":
142142
for var in src_inst._env_variable_sets[var_set]:
143-
assert var in copy_inst._env_variable_sets[var_set]
143+
assert var in clone_inst._env_variable_sets[var_set]
144144

145145
# Test internals:
146146
for internal, conf in src_inst.internals.items():
147-
assert internal in copy_inst.internals
147+
assert internal in clone_inst.internals
148148
if internal == "custom_executables":
149149
for exec_name, exec_conf in conf.items():
150-
assert exec_name in copy_inst.internals[internal]
150+
assert exec_name in clone_inst.internals[internal]
151151
for option, value in exec_conf.items():
152-
assert option in copy_inst.internals[internal][exec_name]
153-
assert copy_inst.internals[internal][exec_name][option] == value
152+
assert option in clone_inst.internals[internal][exec_name]
153+
assert clone_inst.internals[internal][exec_name][option] == value
154154

155155

156156
@pytest.mark.parametrize(
@@ -498,16 +498,16 @@ def test_derive_variables_for_template_path(mutable_mock_apps_repo):
498498

499499
def test_class_attributes(mutable_mock_apps_repo):
500500
basic_inst = mutable_mock_apps_repo.get("basic")
501-
basic_copy = basic_inst.copy()
501+
basic_clone = basic_inst.clone()
502502

503-
instances = [basic_inst, basic_copy]
503+
instances = [basic_inst, basic_clone]
504504
for inst in instances:
505505
assert hasattr(inst, "workloads")
506506
assert "test_wl" in inst.workloads
507507

508-
basic_copy.workload("added_workload", executables=["foo"])
508+
basic_clone.workload("added_workload", executables=["foo"])
509509

510-
assert "added_workload" in basic_copy.workloads
510+
assert "added_workload" in basic_clone.workloads
511511
assert "added_workload" not in basic_inst.workloads
512512

513513

0 commit comments

Comments
 (0)