Skip to content

Commit 454ff28

Browse files
committed
some fixes from review
1 parent 823ef0c commit 454ff28

10 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎paths_cli/commands/compile.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from paths_cli.plugin_management import NamespacePluginLoader
1111
import importlib
1212
from paths_cli.utils import get_installed_plugins
13+
from paths_cli.commands.contents import report_all_tables
1314

1415
# this is just to handle a nicer error
1516
def import_module(module_name, format_type=None, install=None):
@@ -74,9 +75,11 @@ def compile_(input_file, output_file):
7475
register_plugins(plugins)
7576

7677
objs = do_compile(dct)
77-
print(objs)
78+
print(f"Saving {len(objs)} user-specified objects to {output_file}....")
7879
storage = OUTPUT_FILE.get(output_file)
7980
storage.save(objs)
81+
report_all_tables(storage)
82+
8083

8184
PLUGIN = OPSCommandPlugin(
8285
command=compile_,

‎paths_cli/compiling/core.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,22 @@ class Builder:
8585
8686
Additionally, this class provides hooks for functions that run before or
8787
after the main builder function. This allows many objects to be built by
88-
implementing simple functions and hooking themn together with Builder.
88+
implementing simple functions and hooking themn together with Builder,
89+
which can act as a general adaptor between user input and the underlying
90+
functions.
8991
9092
Parameters
9193
----------
9294
builder : Union[Callable, str]
9395
primary callable to build an object, or string representing the
9496
fully-qualified path to a callable
9597
remapper : Callable[[Dict], Dict], optional
96-
callable to remap the the mapping of ???
98+
Callable to remap the input dict (as parsed from user input) to a
99+
dict of keyword arguments for the builder function. This can be
100+
used, e.g., to rename user-facing keys to the internally-used names,
101+
or to add structure if, for example, inputs to the builder function
102+
require structures (such as a dict) that are flattened in user
103+
input, or vice-versa.
97104
after_build : Callable[[Any, Dict], Any], optional
98105
callable to update the created object with any additional
99106
information from the original dictionary.

‎paths_cli/compiling/cvs.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __call__(self, source):
2121
# on ImportError, we leave the error unchanged
2222
return func
2323

24-
def cv_kwargs_remapper(dct):
24+
def _cv_kwargs_remapper(dct):
2525
kwargs = dct.pop('kwargs', {})
2626
dct.update(kwargs)
2727
return dct
@@ -31,7 +31,7 @@ def cv_kwargs_remapper(dct):
3131
MDTRAJ_CV_PLUGIN = CVCompilerPlugin(
3232
builder=Builder('openpathsampling.experimental.storage.'
3333
'collective_variables.MDTrajFunctionCV',
34-
remapper=cv_kwargs_remapper),
34+
remapper=_cv_kwargs_remapper),
3535
parameters=[
3636
Parameter('topology', build_topology),
3737
Parameter('func', AllowedPackageHandler('mdtraj'),

‎paths_cli/compiling/engines.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def load_openmm_xml(filename):
2020

2121
return obj
2222

23-
def openmm_options(dct):
23+
def _openmm_options(dct):
2424
n_steps_per_frame = dct.pop('n_steps_per_frame')
2525
n_frames_max = dct.pop('n_frames_max')
2626
options = {'n_steps_per_frame': n_steps_per_frame,
@@ -46,7 +46,7 @@ def openmm_options(dct):
4646

4747
OPENMM_PLUGIN = EngineCompilerPlugin(
4848
builder=Builder('openpathsampling.engines.openmm.Engine',
49-
remapper=openmm_options),
49+
remapper=_openmm_options),
5050
parameters=OPENMM_PARAMETERS,
5151
name='openmm',
5252
)

‎paths_cli/compiling/schemes.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def __call__(self, **dct):
4343
scheme = builder(**dct)
4444
for strat in strategies:
4545
scheme.append(strat)
46-
self.logger.debug(f"strategies: {scheme.strategies}")
4746
return scheme
4847

4948

‎paths_cli/compiling/shooting.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
name='uniform',
1111
)
1212

13-
def remapping_gaussian_stddev(dct):
13+
def _remapping_gaussian_stddev(dct):
1414
dct['alpha'] = 0.5 / dct.pop('stddev')**2
1515
dct['collectivevariable'] = dct.pop('cv')
1616
dct['l_0'] = dct.pop('mean')
1717
return dct
1818

1919
build_gaussian_selector = InstanceCompilerPlugin(
2020
builder=Builder('openpathsampling.GaussianBiasSelector',
21-
remapper=remapping_gaussian_stddev),
21+
remapper=_remapping_gaussian_stddev),
2222
parameters=[
2323
Parameter('cv', compiler_for('cv')),
2424
Parameter('mean', custom_eval),

‎paths_cli/tests/commands/test_compile.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def test_compile(ad_openmm, test_data_dir):
8484
print(result.exception)
8585
print(result.exc_info)
8686
print(result.output)
87-
assert result.exit_code == 0
8887
assert os.path.exists(str(ad_openmm / 'setup.db'))
8988
import openpathsampling as paths
9089
from openpathsampling.experimental.storage import (

‎paths_cli/tests/commands/test_contents.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_contents(tps_fixture):
3838
f"Snapshots: {2*len(init_conds[0])} unnamed items", ""
3939
]
4040
assert_click_success(results)
41-
assert results.exit_code == 0
4241
assert results.output.split('\n') == expected
4342
for truth, beauty in zip(expected, results.output.split('\n')):
4443
assert truth == beauty
@@ -75,7 +74,6 @@ def test_contents_table(tps_fixture, table):
7574
}[table]
7675
assert results.output.split("\n") == expected
7776
assert_click_success(results)
78-
assert results.exit_code == 0
7977

8078
def test_contents_table_error():
8179
runner = CliRunner()

‎paths_cli/tests/compiling/test_engines.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44

55
from paths_cli.compiling.engines import *
6+
from paths_cli.compiling.engines import _openmm_options
67
from paths_cli.compiling.errors import InputError
78
import openpathsampling as paths
89

@@ -53,7 +54,7 @@ def test_load_openmm_xml(self, tmpdir):
5354

5455
def test_openmm_options(self):
5556
dct = yaml.load(self.yml, yaml.FullLoader)
56-
dct = openmm_options(dct)
57+
dct = _openmm_options(dct)
5758
assert dct == {'type': 'openmm', 'name': 'engine',
5859
'system': 'system.xml',
5960
'integrator': 'integrator.xml',

‎paths_cli/tests/compiling/test_shooting.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
from paths_cli.compiling.shooting import *
4+
from paths_cli.compiling.shooting import _remapping_gaussian_stddev
45
import openpathsampling as paths
56
from paths_cli.tests.compiling.utils import mock_compiler
67

@@ -13,7 +14,7 @@ def test_remapping_gaussian_stddev(cv_and_states):
1314
cv, _, _ = cv_and_states
1415
dct = {'cv': cv, 'mean': 1.0, 'stddev': 2.0}
1516
expected = {'collectivevariable': cv, 'l_0': 1.0, 'alpha': 0.125}
16-
results = remapping_gaussian_stddev(dct)
17+
results = _remapping_gaussian_stddev(dct)
1718
assert results == expected
1819

1920
def test_build_gaussian_selector(cv_and_states):

0 commit comments

Comments
 (0)