Skip to content

Commit

Permalink
Merge pull request #156 from molssi-seamm/dev
Browse files Browse the repository at this point in the history
Bugfix: running flowcharts from the commandline.
  • Loading branch information
seamm authored Nov 15, 2023
2 parents 522fb46 + 7eae77d commit 754bfd7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
=======
History
=======
2023.11.15 -- Add boolean options when submitting jobs
* Added boolean control parameters when submitting jobs.
* Bugfix: The previous change to allow running "flowchart.flow" in the current
directory caused a bug in other scenarios.

2023.11.12 -- Allowing running flowchart.flow in current directory
* There was a feature which prevented running a flowchart named "flowchart.flow" in
the current directory when running from the commandline.
Expand Down
7 changes: 5 additions & 2 deletions seamm/run_flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ def run(
path = Path(sys.argv[0]).resolve()

# copy the flowchart to the root directory if it is not there already
if not in_jobserver and flowchart_path.exists() and path != flowchart_path:
shutil.copy2(path, flowchart_path)
if not in_jobserver:
if flowchart_path.exists() and path == flowchart_path:
pass
else:
shutil.copy2(path, flowchart_path)

# Make executable if it isn't
permissions = flowchart_path.stat().st_mode
Expand Down
37 changes: 29 additions & 8 deletions seamm/tk_job_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, root=None):
self._flowchart = None
self._widgets = {}
self._variable_value = {}
self._tk_var = {} # For checkbuttons
self.resource_path = Path(pkg_resources.resource_filename(__name__, "data/"))

s = ttk.Style()
Expand Down Expand Up @@ -810,14 +811,29 @@ def submit_with_dialog(self, flowchart):
d.rowconfigure(7, weight=1)
row = 0
for step in parameter_steps:
variables = step.parameters["variables"]
for name, data in variables.value.items():
variables = {**step.parameters["variables"].value}
for name, data in variables.items():
table[row, 0] = name
if name not in value or value[name] is None:
value[name] = data["default"]
entry = ttk.Entry(frame)
entry.insert(0, value[name])
table[row, 1] = entry
table[row, 0].grid(sticky=tk.E)
if data["type"] == "bool":
if name not in value or value[name] is None:
value[name] = False
var = self._tk_var[name] = tk.IntVar()
checkbox = ttk.Checkbutton(frame, variable=var)
var.set(1 if value[name] else 0)
table[row, 1] = checkbox
else:
if name not in value or value[name] is None:
value[name] = data["default"]
if len(data["choices"]) > 0:
combo = ttk.Combobox(frame, values=data["choices"])
combo.set(value[name])
combo.configure(state="readonly")
table[row, 1] = combo
else:
entry = ttk.Entry(frame)
entry.insert(0, value[name])
table[row, 1] = entry
table[row, 1].grid(sticky=tk.EW)
if data["type"] == "file":
button = tk.Button(
Expand Down Expand Up @@ -845,7 +861,12 @@ def submit_with_dialog(self, flowchart):
table = self["parameters"]
for row in range(table.nrows):
name = table[row, 0].cget("text")
value[name] = table[row, 1].get()
data = variables[name]
if data["type"] == "bool":
tmp = self._tk_var[name].get()
value[name] = True if tmp == 1 else False
else:
value[name] = table[row, 1].get()

dashboard_name = result.pop("dashboard")
dashboard = self.dashboard_handler.get_dashboard(dashboard_name)
Expand Down

0 comments on commit 754bfd7

Please sign in to comment.