Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7af7eae
Add start to wizard
dwhswenson Feb 18, 2021
7fec891
TPS wizard works through state defs
dwhswenson Feb 19, 2021
250f4e2
a little more work on the wizard
dwhswenson Feb 27, 2021
666f9a9
major steps toward TPS wizard
dwhswenson Mar 4, 2021
8910ba2
A little more cleanup on wizard stuff
dwhswenson Mar 4, 2021
0b60338
Start to add tests for wizard
dwhswenson Mar 4, 2021
68066b1
tests for most of the Wizard object
dwhswenson Mar 6, 2021
4da1b9a
move MockConsole, start to get_object decorator
dwhswenson Mar 6, 2021
c17f3d1
more work toward using get_object
dwhswenson Mar 6, 2021
77fa5ce
tests for OpenMM wizard
dwhswenson Mar 6, 2021
76ea517
Prep tests for CVs
dwhswenson Mar 7, 2021
5d2e3f8
Some CV cleanup; more periodicity to CVs
dwhswenson Mar 7, 2021
b5ec9ce
Wizard ready for 2-state TPS demo
dwhswenson Mar 7, 2021
b32d03a
Add tests for CV wizards
dwhswenson Mar 7, 2021
a52bac0
tests for volume wizards
dwhswenson Mar 8, 2021
a9c4d96
simplify code to reflect current usage
dwhswenson Mar 8, 2021
a85118f
more cleanup of unused
dwhswenson Mar 8, 2021
42aa3c9
More tests; work toward handling Spring Shooting
dwhswenson Mar 18, 2021
13f7108
fix up tests
dwhswenson Mar 18, 2021
9d6c3dd
Add tests for shooting, load_from_ops
dwhswenson Mar 18, 2021
6467b59
Remove name from core (used as wizard.name)
dwhswenson Mar 19, 2021
d2050e4
Add tests for TPS wizard
dwhswenson Mar 20, 2021
94cd34e
Tests for two_state_tps.py
dwhswenson Mar 20, 2021
3f183de
tests for engines and errors
dwhswenson Mar 20, 2021
35c9ca1
Update for parsing.tools.custom_eval
dwhswenson Mar 26, 2021
97189a6
split off _do_one in wizard
dwhswenson Mar 26, 2021
f932fce
Add remaining tests for wizard
dwhswenson Jun 18, 2021
a3c7b4b
from unittest import mock...
dwhswenson Jun 18, 2021
a7fefd2
missed one
dwhswenson Jun 18, 2021
9259aca
fix for tests locally
dwhswenson Jun 18, 2021
10b676d
try ignoring wizard (does that fix test errors?)
dwhswenson Jun 18, 2021
8b7c8b8
re-include wizard tests
dwhswenson Jun 18, 2021
6c37dce
don't actually monkeypatch when testing Wizard
dwhswenson Jun 18, 2021
d444895
fix deprecation warnings for OPS 1.5
dwhswenson Jul 6, 2021
47106e6
Add Wizard (skeleton form) to docs
dwhswenson Jul 7, 2021
e9dd815
Add test job with openmm etc integrations
dwhswenson Jul 7, 2021
ea29ac4
fix whitespace in yaml
dwhswenson Jul 7, 2021
b52c1ef
fix include in yaml
dwhswenson Jul 7, 2021
3b64ce7
fix typo in workflow
dwhswenson Jul 7, 2021
8dcd07d
fix workflow
dwhswenson Jul 7, 2021
e774caa
increase fetch-depth to help codecov
dwhswenson Jul 7, 2021
d07699e
... helps is fetch-depth is in the right heading
dwhswenson Jul 7, 2021
2ba6390
finish test coverage
dwhswenson Jul 24, 2021
59b6fbe
Add test for bad MDTraj atom index input
dwhswenson Jul 24, 2021
4f3e53a
Add tests/wizard/__init__.py
dwhswenson Jul 24, 2021
0b33b79
no-cov on joke
dwhswenson Jul 24, 2021
60eb119
Apply suggestions from code review
dwhswenson Jul 26, 2021
3d92cd2
misc review cleanup
dwhswenson Jul 26, 2021
07b7d7c
Merge branch 'main' of github.com:openpathsampling/openpathsampling-c…
dwhswenson Jul 27, 2021
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
Prev Previous commit
Next Next commit
move MockConsole, start to get_object decorator
  • Loading branch information
dwhswenson committed Mar 6, 2021
commit 4da1b9a2f34bd5dffb96ca2cec94019f8bcbc520
33 changes: 33 additions & 0 deletions paths_cli/tests/wizard/mock_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,36 @@ def make_mock_retry_wizard(inputs):
wizard = Wizard([])
wizard.console.input = mock.Mock(side_effect=inputs)
return wizard

class MockConsole:
def __init__(self, inputs=None):
if isinstance(inputs, str):
inputs = [inputs]
elif inputs is None:
inputs = []
self.inputs = inputs
self._input_iter = iter(inputs)
self.log = []
self.width = 80
self.input_call_count = 0

def print(self, content=""):
self.log.append(content)

def input(self, content):
self.input_call_count += 1
user_input = next(self._input_iter)
self.log.append(content + " " + user_input)
return user_input

@property
def log_text(self):
return "\n".join(self.log)

def mock_wizard(inputs):
wizard = Wizard([])
console = MockConsole(inputs)
wizard.console = console
return wizard


26 changes: 1 addition & 25 deletions paths_cli/tests/wizard/test_wizard.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import mock
from paths_cli.tests.wizard.mock_wizard import (
make_mock_wizard, make_mock_retry_wizard
MockConsole
)
import pathlib

Expand All @@ -10,30 +10,6 @@

from paths_cli.wizard.wizard import *

class MockConsole:
def __init__(self, inputs=None):
if isinstance(inputs, str):
inputs = [inputs]
elif inputs is None:
inputs = []
self.inputs = inputs
self._input_iter = iter(inputs)
self.log = []
self.width = 80
self.input_call_count = 0

def print(self, content=""):
self.log.append(content)

def input(self, content):
self.input_call_count += 1
user_input = next(self._input_iter)
self.log.append(content + " " + user_input)
return user_input

@property
def log_text(self):
return "\n".join(self.log)


class TestWizard:
Expand Down
8 changes: 8 additions & 0 deletions paths_cli/wizard/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ def get_missing_object(wizard, obj_dict, display_name, fallback_func):
obj = obj_dict[sel]
return obj


def get_object(func):
def inner(*args, **kwargs):
obj = None
while obj is None:
obj = func(*args, **kwargs)
return obj
return inner
35 changes: 13 additions & 22 deletions paths_cli/wizard/openmm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from paths_cli.wizard.errors import FILE_LOADING_ERROR_MSG, not_installed
from paths_cli.wizard.core import get_object
try:
from simtk import openmm as mm
import mdtraj as md
Expand All @@ -16,6 +17,7 @@ def _openmm_serialization_helper(wizard, user_input): # no-cov
"simtk.openmm.openmm.XmlSerializer.html")


@get_object
def _load_openmm_xml(wizard, obj_type):
xml = wizard.ask(
f"Where is the XML file for your OpenMM {obj_type}?",
Expand All @@ -30,20 +32,17 @@ def _load_openmm_xml(wizard, obj_type):
else:
return obj

@get_object
def _load_topology(wizard):
import openpathsampling as paths
topology = None
while topology is None:
filename = wizard.ask("Where is a PDB file describing your system?")
try:
snap = paths.engines.openmm.snapshot_from_pdb(filename)
except Exception as e:
wizard.exception(FILE_LOADING_ERROR_MSG, e)
continue

topology = snap.topology
filename = wizard.ask("Where is a PDB file describing your system?")
try:
snap = paths.engines.openmm.snapshot_from_pdb(filename)
except Exception as e:
wizard.exception(FILE_LOADING_ERROR_MSG, e)
return

return topology
return snap.topology

def openmm(wizard):
import openpathsampling as paths
Expand All @@ -56,17 +55,9 @@ def openmm(wizard):
"To use OpenMM in OPS, you need to provide XML versions of "
"your system, integrator, and some file containing "
"topology information.")
system = integrator = topology = None
while system is None:
system = _load_openmm_xml(wizard, 'system')

while integrator is None:
integrator = _load_openmm_xml(wizard, 'integrator')

while topology is None:
topology = _load_topology(wizard)

n_frames_max = n_steps_per_frame = None
system = _load_openmm_xml(wizard, 'system')
integrator = _load_openmm_xml(wizard, 'integrator')
topology = _load_topology(wizard)

n_steps_per_frame = wizard.ask_custom_eval(
"How many MD steps per saved frame?", type_=int
Expand Down