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

Replace custom configuration definition with standard approach #244

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions datalad_container/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,19 @@
]
)

from datalad.support.extensions import register_config
from os.path import join as opj
from datalad.support.constraints import EnsureStr

register_config(
'datalad.containers.location',
'Container location',
description='path within the dataset where to store containers',
type=EnsureStr(),
default=opj(".datalad", "environments"),
dialog='question',
scope='dataset',
)

from . import _version
__version__ = _version.get_versions()['version']
9 changes: 0 additions & 9 deletions datalad_container/containers_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from datalad.interface.results import get_status_dict

from .utils import get_container_configuration
from .definitions import definitions

lgr = logging.getLogger("datalad.containers.containers_add")

Expand Down Expand Up @@ -233,20 +232,12 @@ def __call__(name, url=None, dataset=None, call_fmt=None, image=None,

if not image:
loc_cfg_var = "datalad.containers.location"
# TODO: We should provide an entry point (or sth similar) for extensions
# to get config definitions into the ConfigManager. In other words an
# easy way to extend definitions in datalad's common_cfgs.py.
container_loc = \
ds.config.obtain(
loc_cfg_var,
where=definitions[loc_cfg_var]['destination'],
# if not False it would actually modify the
# dataset config file -- undesirable
store=False,
default=definitions[loc_cfg_var]['default'],
dialog_type=definitions[loc_cfg_var]['ui'][0],
valtype=definitions[loc_cfg_var]['type'],
**definitions[loc_cfg_var]['ui'][1]
)
image = op.join(ds.path, container_loc, name, 'image')
else:
Expand Down
13 changes: 0 additions & 13 deletions datalad_container/definitions.py

This file was deleted.