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

Assorted code cleanup #422

Merged
merged 6 commits into from
Feb 25, 2021
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
2 changes: 0 additions & 2 deletions dandi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def set_logger_level(lgr, level):
lgr.setLevel(level)


_DEFAULT_LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

lgr = get_logger()
# Basic settings for output, for now just basic
set_logger_level(lgr, os.environ.get("DANDI_LOG_LEVEL", logging.INFO))
Expand Down
5 changes: 1 addition & 4 deletions dandi/dandiset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Classes/utilities for support of a dandiset"""
import json
import os
from pathlib import Path

Expand Down Expand Up @@ -149,6 +148,4 @@ def _load_metadata(self):
# models as metadata, so we take dict representation
# Do R/T through json since it then maps types, although
# "access" has a side-effect: https://github.com/dandi/dandi-cli/issues/343
self.metadata = json.loads(
migrate2newschema(self.metadata).json(exclude_unset=True, exclude_none=True)
)
self.metadata = migrate2newschema(self.metadata).json_dict()
4 changes: 2 additions & 2 deletions dandi/tests/test_organize.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_organize_nwb_test_data(nwb_test_data, tmpdir, clirunner, mode):
assert not any(op.islink(p) for p in produced_paths)


def test_ambigous(simple2_nwb, tmp_path, clirunner):
def test_ambiguous(simple2_nwb, tmp_path, clirunner):
copy2 = copy_nwb_file(simple2_nwb, tmp_path)
outdir = str(tmp_path / "organized")
args = ["--files-mode", "copy", "-d", outdir, simple2_nwb, copy2]
Expand All @@ -198,7 +198,7 @@ def test_ambigous(simple2_nwb, tmp_path, clirunner):
)


def test_ambiguos_probe1():
def test_ambiguous_probe1():
base = dict(subject_id="1", session="2", extension="nwb")
# fake filenames should be ok since we never should get to reading them for object_id
metadata = [
Expand Down
20 changes: 7 additions & 13 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,13 @@ def ensure_strtime(t, isoformat=True):
raise TypeError(f"Do not know how to convert {t_orig!r} to string datetime")


def fromisoformat(t, impl=None):
if impl is None:
# datetime parser "does not support parsing arbitrary ISO 8601 strings"
# https://docs.python.org/3/library/datetime.html
# In particular it does not parse time zone suffix which was recently
# introduced into datetime's provided by API
impl = "dateutil"
if impl == "datetime":
return datetime.datetime.fromisoformat(t)
elif impl == "dateutil":
return dateutil.parser.isoparse(t)
else:
raise ValueError(impl)
def fromisoformat(t):
# datetime.fromisoformat "does not support parsing arbitrary ISO 8601
# strings" <https://docs.python.org/3/library/datetime.html>. In
# particular, it does not parse the time zone suffixes recently
# introduced into timestamps provided by the API. Hence, we need to use
# dateutil instead.
return dateutil.parser.isoparse(t)


def ensure_datetime(t, strip_tzinfo=False, tz=None):
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ description = Command line client for interaction with DANDI archive elements
long_description = file:README.md
long_description_content_type = text/markdown; charset=UTF-8
platforms = OS Independent
provides =
dandi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious: where it potentially could be used? I found no description on https://packaging.python.org/guides/distributing-packages-using-setuptools

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in the ecosystem currently uses this field. There are occasional discussions around using "Provides" to implement support for things like virtual packages, but nothing ever comes of it.

project_urls =
Source Code = https://github.com/dandi/dandi-cli

Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extras = test
commands =
# Using pytest-cov instead of using coverage directly leaves a bunch of
# .coverage.$HOSTNAME.#.# files lying around for some reason
coverage erase
coverage run -m pytest -v {posargs} dandi
coverage combine
coverage report
Expand Down