Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate TypeConfig #1829

Merged
merged 51 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
52cb3c5
integration
mavaylon1 Jan 18, 2024
18911f2
path
mavaylon1 Jan 19, 2024
0908d65
clean up
mavaylon1 Jan 19, 2024
37939f3
update
mavaylon1 Jan 25, 2024
97487be
Delete out.txt
mavaylon1 Jan 25, 2024
e50d951
update
mavaylon1 Jan 25, 2024
0caa44a
need to clean
mavaylon1 Jan 31, 2024
5bd2a25
partial clean up
mavaylon1 Jan 31, 2024
9fdd1c3
Merge branch 'dev' into tmc
mavaylon1 Jan 31, 2024
ac8d839
checkpoint
mavaylon1 Feb 21, 2024
b3fcbf8
checkpoint
mavaylon1 Mar 3, 2024
66747de
check
mavaylon1 Mar 3, 2024
db64e6b
Merge branch 'dev' into tmc
mavaylon1 Apr 8, 2024
9f54ac6
Delete docs/source/sg_execution_times.rst
mavaylon1 Apr 8, 2024
c02993b
Update ecephys.py
mavaylon1 Apr 8, 2024
4572954
checkpoint
mavaylon1 Apr 8, 2024
49215a5
test
mavaylon1 Apr 8, 2024
372dfcf
test
mavaylon1 Apr 8, 2024
14fef28
update
mavaylon1 Apr 10, 2024
2dcc091
checkpoint passing
mavaylon1 Apr 10, 2024
ba7e851
Merge branch 'dev' into tmc
mavaylon1 May 20, 2024
f39aae5
clean up
mavaylon1 May 20, 2024
7adf428
tutorial draft
mavaylon1 May 20, 2024
cfd1561
docs
mavaylon1 May 20, 2024
d1bc20f
checkpoint
mavaylon1 May 20, 2024
7613f36
subject
mavaylon1 May 21, 2024
4f5854a
gallery
mavaylon1 May 21, 2024
d0f1b87
gallery
mavaylon1 May 21, 2024
c75db7d
Update requirements-min.txt
mavaylon1 May 21, 2024
8a875fa
Update requirements.txt
mavaylon1 May 21, 2024
9f8e856
rebase
mavaylon1 May 21, 2024
72bb2a9
test
mavaylon1 May 21, 2024
209a07d
test
mavaylon1 May 21, 2024
091631f
coverage
mavaylon1 May 21, 2024
453c56d
Create requirements-opt.txt
mavaylon1 May 21, 2024
ffdb838
Update check_sphinx_links.yml
mavaylon1 May 21, 2024
f63d59d
link
mavaylon1 May 21, 2024
078149f
Update tox.ini
mavaylon1 May 21, 2024
f3e1c1c
Update run_coverage.yml
mavaylon1 May 21, 2024
e2436ac
Update tox.ini
mavaylon1 May 21, 2024
bc1fc67
Update run_coverage.yml
rly May 21, 2024
6fbd681
Update docs/gallery/general/plot_configurator.py
mavaylon1 May 21, 2024
4dd4ca1
Update docs/gallery/general/plot_configurator.py
mavaylon1 May 21, 2024
355046a
feedback
mavaylon1 May 22, 2024
d1d7fea
Update CHANGELOG.md
mavaylon1 May 22, 2024
1b6e20d
Update plot_configurator.py
rly May 22, 2024
b972603
Update plot_configurator.py
mavaylon1 May 22, 2024
c8e81e3
Update docs/gallery/general/nwb_gallery_config.yaml
mavaylon1 May 22, 2024
8f2a1f1
Update src/pynwb/config/nwb_config.yaml
mavaylon1 May 22, 2024
981a7b6
Merge branch 'dev' into tmc
rly May 22, 2024
4fe39f0
Merge branch 'dev' into tmc
mavaylon1 May 22, 2024
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
39 changes: 39 additions & 0 deletions docs/gallery/general/plot_configurator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from pynwb import nwb_config
from datetime import datetime
from uuid import uuid4

import numpy as np
from dateutil import tz

from pynwb import NWBHDF5IO, NWBFile, TimeSeries
from pynwb.behavior import Position, SpatialSeries
from pynwb.epoch import TimeIntervals
from pynwb.file import Subject

session_start_time = datetime(2018, 4, 25, 2, 30, 3, tzinfo=tz.gettz("US/Pacific"))

nwbfile = NWBFile(
session_description="Mouse exploring an open field", # required
identifier=str(uuid4()), # required
session_start_time=session_start_time, # required
session_id="session_1234", # optional
experimenter=[
"Baggins, Bilbo",
], # optional
lab="Bag End Laboratory", # optional
institution="University of My Institution", # optional
experiment_description="I went on an adventure to reclaim vast treasures.", # optional
related_publications="DOI:10.1016/j.neuron.2016.12.011", # optional
)


subject = Subject(
subject_id="001",
age="P90D",
description="mouse 5",
species="Mus musculus",
sex="M",
)

nwbfile.subject = subject
breakpoint()
340 changes: 340 additions & 0 deletions out.txt

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@
from .spec import NWBDatasetSpec, NWBGroupSpec, NWBNamespace # noqa E402
from .validate import validate # noqa: F401, E402

from .termset_config import NWBTermSetConfigurator


nwb_config = NWBTermSetConfigurator(path='src/pynwb/config/nwb_config.yaml')
mavaylon1 marked this conversation as resolved.
Show resolved Hide resolved

@docval({'name': 'config_path', 'type': str, 'doc': 'Path to the configuartion file.',

Check failure on line 26 in src/pynwb/__init__.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

configuartion ==> configuration
'default': None})
def load_termset_config(config_path: str):
"""
If a user does not provide a config_path, then this method will unload any present configuration
and load the default curated configuration.

If a user provides a config_path, then this method will:
- Search the current configuation for data_types that are already present. These data_types will be

Check failure on line 34 in src/pynwb/__init__.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

configuation ==> configuration
replaced with the new configuration.
- If the data_type is not present, then they will be loaded alongside the default curated configuration.
"""
if config_path is None:
nwb_config.unload_termset_config()
nwb_config.load_termset_config()
else:
nwb_config.load_termset_config(config_path)

def unload_termset_config():
"""
Remove validation.
"""
return nwb_config.unload_termset_config()


def __get_resources():
try:
Expand Down
6 changes: 6 additions & 0 deletions src/pynwb/config/nwb_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Subject:
namespace:
namespace_version:
fields:
species: src/pynwb/config/nwb_subject_termset.yaml
# field2: ...
27 changes: 27 additions & 0 deletions src/pynwb/config/nwb_subject_termset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
id: termset/species_example
name: Species
version: 0.0.1
prefixes:
NCBI_TAXON: https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=
imports:
- linkml:types
default_range: string

enums:
Species:
permissible_values:
Homo sapiens:
description: the species is human
meaning: NCBI_TAXON:9606
Mus musculus:
description: the species is a house mouse
meaning: NCBI_TAXON:10090
Ursus arctos horribilis:
description: the species is a grizzly bear
meaning: NCBI_TAXON:116960
Myrmecophaga tridactyla:
description: the species is an anteater
meaning: NCBI_TAXON:71006
Ailuropoda melanoleuca:
description: the species is a panda
meaning: NCBI_TAXON:9646
9 changes: 9 additions & 0 deletions src/pynwb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def _error_on_new_warn_on_construct(self, error_msg: str):
raise ValueError(error_msg)
warn(error_msg)

def get_config(self):
from . import nwb_config #update path
return nwb_config

def get_type_map(self):
from . import get_type_map
tm = get_type_map()
return tm


@register_class('NWBContainer', CORE_NAMESPACE)
class NWBContainer(NWBMixin, Container):
Expand Down
1 change: 1 addition & 0 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Subject(NWBContainer):
{'name': 'strain', 'type': str, 'doc': 'The strain of the subject, e.g., "C57BL/6J"', 'default': None},
)
def __init__(self, **kwargs):
self.init_validation(constructor_args=kwargs)
keys_to_set = (
"age",
"age__reference",
Expand Down
12 changes: 12 additions & 0 deletions src/pynwb/termset_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from hdmf.term_set import TermSetConfigurator as hdmf_TermSetConfigurator
from hdmf.utils import docval


class NWBTermSetConfigurator(hdmf_TermSetConfigurator):
"""

"""
@docval({'name': 'path', 'type': str, 'doc': 'Path to the configuartion file.',

Check failure on line 9 in src/pynwb/termset_config.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

configuartion ==> configuration
'default': 'src/pynwb/config/nwb_config.yaml'})
def __init__(self,**kwargs):
super().__init__(**kwargs)
2 changes: 2 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from pynwb import nwb_config
breakpoint()
Loading