Skip to content

Commit 16e4347

Browse files
committed
Merge branch 'docker-img-refactor' into migrate-pyproject
2 parents fc5a27f + 4ee287c commit 16e4347

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

datajoint/dependencies.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def topo_sort(graph):
5656
pos -= 1
5757
else:
5858
placed.add(part)
59-
j = sorted_nodes.index(master)
60-
if pos > j + 1:
61-
# move the part to its master
59+
insert_pos = sorted_nodes.index(master) + 1
60+
if pos > insert_pos:
61+
# move the part to the position immediately after its master
6262
del sorted_nodes[pos]
63-
sorted_nodes.insert(j + 1, part)
63+
sorted_nodes.insert(insert_pos, part)
6464

6565
return sorted_nodes
6666

datajoint/external.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .table import Table, FreeTable
99
from .heading import Heading
1010
from .declare import EXTERNAL_TABLE_ROOT
11-
from . import s3
11+
from . import s3, errors
1212
from .utils import safe_write, safe_copy
1313

1414
logger = logging.getLogger(__name__.split(".")[0])
@@ -141,7 +141,12 @@ def _download_buffer(self, external_path):
141141
if self.spec["protocol"] == "s3":
142142
return self.s3.get(external_path)
143143
if self.spec["protocol"] == "file":
144-
return Path(external_path).read_bytes()
144+
try:
145+
return Path(external_path).read_bytes()
146+
except FileNotFoundError:
147+
raise errors.MissingExternalFile(
148+
f"Missing external file {external_path}"
149+
) from None
145150
assert False
146151

147152
def _remove_external_file(self, external_path):

datajoint/settings.py

+7
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ def __setitem__(self, key, value):
246246
self._conf[key] = value
247247
else:
248248
raise DataJointError("Validator for {0:s} did not pass".format(key))
249+
valid_logging_levels = {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
250+
if key == "loglevel":
251+
if value not in valid_logging_levels:
252+
raise ValueError(f"{'value'} is not a valid logging value")
253+
logger.setLevel(value)
249254

250255

251256
# Load configuration from file
@@ -270,6 +275,7 @@ def __setitem__(self, key, value):
270275
"database.password",
271276
"external.aws_access_key_id",
272277
"external.aws_secret_access_key",
278+
"loglevel",
273279
),
274280
map(
275281
os.getenv,
@@ -279,6 +285,7 @@ def __setitem__(self, key, value):
279285
"DJ_PASS",
280286
"DJ_AWS_ACCESS_KEY_ID",
281287
"DJ_AWS_SECRET_ACCESS_KEY",
288+
"DJ_LOG_LEVEL",
282289
),
283290
),
284291
)

tests/test_dependencies.py

+20
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ def test_nullable_dependency(thing_tables):
1919
assert len(c) == len(c.fetch()) == 5
2020

2121

22+
def test_topo_sort():
23+
import networkx as nx
24+
import datajoint as dj
25+
26+
graph = nx.DiGraph(
27+
[
28+
("`a`.`a`", "`a`.`m`"),
29+
("`a`.`a`", "`a`.`z`"),
30+
("`a`.`m`", "`a`.`m__part`"),
31+
("`a`.`z`", "`a`.`m__part`"),
32+
]
33+
)
34+
assert dj.dependencies.topo_sort(graph) == [
35+
"`a`.`a`",
36+
"`a`.`z`",
37+
"`a`.`m`",
38+
"`a`.`m__part`",
39+
]
40+
41+
2242
def test_unique_dependency(thing_tables):
2343
"""test nullable unique foreign key"""
2444
# Thing C has a nullable dependency on B whose primary key is composite

0 commit comments

Comments
 (0)