Skip to content

Commit

Permalink
Support static host info methods in project registration
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Oct 8, 2020
1 parent a574752 commit 59d0a18
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Unreleased

- Support static host info methods in Registration
- New `find_experiments` method to simplify recursive search for experiments in a given directory

## v2.5.2
Expand Down
2 changes: 1 addition & 1 deletion src/machinable/storage/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .views import StorageExperimentView, StorageComponentView, StorageView
from .views import StorageComponentView, StorageExperimentView, StorageView
3 changes: 2 additions & 1 deletion src/machinable/utils/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def get_host_info(registration=True):
if registration:
registration = Registration.get()
for name, method in inspect.getmembers(
registration, predicate=inspect.ismethod
registration,
predicate=lambda x: inspect.isfunction(x) or inspect.ismethod(x),
):
if name.startswith("host_"):
_getters[name[5:]] = method
Expand Down
5 changes: 4 additions & 1 deletion tests/storage/storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def test_storage_experiment():
assert o.project_name == "test_project"
assert o.url == "osfs://./_test_data/storage/tttttt"
assert o.components.first().config.test
assert o.host.test_info == "test_info"
assert o.host.test_info_static == "static_test_info"
assert len(o.host) == 10
assert len(o.components) == 4

experiments = o.experiments
Expand All @@ -51,7 +54,7 @@ def test_component_storage():
assert comp.store("key") == "value"
assert "test" in comp.store()
assert len(comp.store()["__files"])
assert len(comp.host) == 9
assert len(comp.host) == 10
assert len(comp.get_records()) == 2

comp = get_experiment(get_path("subdirectory/TTTTTT"))
Expand Down
4 changes: 4 additions & 0 deletions tests/test_project/_machinable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class Project(Registration):
def config_global_conf(self, works=False):
return works

@staticmethod
def host_test_info_static():
return "static_test_info"

def host_test_info(self):
return "test_info"

Expand Down

0 comments on commit 59d0a18

Please sign in to comment.