Skip to content
10 changes: 0 additions & 10 deletions src/datajoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"conn",
"Connection",
"Schema",
"schema",
"VirtualModule",
"virtual_schema",
"list_schemas",
Expand All @@ -40,8 +39,6 @@
"Top",
"U",
"Diagram",
"Di",
"ERD",
"kill",
"MatCell",
"MatStruct",
Expand All @@ -56,8 +53,6 @@
"errors",
"migrate",
"DataJointError",
"key",
"key_hash",
"logger",
"cli",
"ValidationResult",
Expand All @@ -81,7 +76,6 @@
from .connection import Connection, conn
from .errors import DataJointError
from .expression import AndList, Not, Top, U
from .hash import key_hash
from .logging import logger
from .objectref import ObjectRef
from .schemas import Schema, VirtualModule, list_schemas, virtual_schema
Expand All @@ -90,8 +84,6 @@
from .user_tables import Computed, Imported, Lookup, Manual, Part
from .version import __version__

schema = Schema # Alias for Schema

# =============================================================================
# Lazy imports — heavy dependencies loaded on first access
# =============================================================================
Expand All @@ -101,8 +93,6 @@
_lazy_modules = {
# Diagram imports networkx and matplotlib
"Diagram": (".diagram", "Diagram"),
"Di": (".diagram", "Diagram"),
"ERD": (".diagram", "Diagram"),
"diagram": (".diagram", None), # Return the module itself
# kill imports pymysql via connection
"kill": (".admin", "kill"),
Expand Down
4 changes: 3 additions & 1 deletion src/datajoint/autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@ def handler(signum, frame):
if refresh is None:
refresh = config.jobs.auto_refresh
if refresh:
self.jobs.refresh(*restrictions, priority=priority)
# Use delay=-1 to ensure jobs are immediately schedulable
# (avoids race condition with scheduled_time <= NOW(3) check)
self.jobs.refresh(*restrictions, priority=priority, delay=-1)

# Fetch pending jobs ordered by priority (use NOW(3) to match CURRENT_TIMESTAMP(3) precision)
pending_query = self.jobs.pending & "scheduled_time <= NOW(3)"
Expand Down
6 changes: 4 additions & 2 deletions src/datajoint/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def unpack(self, blob):
self._pos += len(prefix)
blob_size = self.read_value()
blob = compression[prefix](self._blob[self._pos :])
assert len(blob) == blob_size
if len(blob) != blob_size:
raise DataJointError(f"Blob size mismatch: expected {blob_size}, got {len(blob)}")
self._blob = blob
self._pos = 0
blob_format = self.read_zero_terminated_string()
Expand Down Expand Up @@ -363,7 +364,8 @@ def read_int(self):
@staticmethod
def pack_int(v):
n_bytes = v.bit_length() // 8 + 1
assert 0 < n_bytes <= 0xFFFF, "Integers are limited to 65535 bytes"
if not (0 < n_bytes <= 0xFFFF):
raise DataJointError("Integers are limited to 65535 bytes")
return b"\x0a" + np.uint16(n_bytes).tobytes() + v.to_bytes(n_bytes, byteorder="little", signed=True)

def read_bool(self):
Expand Down
2 changes: 1 addition & 1 deletion src/datajoint/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def __enter__(self) -> "Connection":
Examples
--------
>>> with dj.Connection(host, user, password) as conn:
... schema = dj.schema('my_schema', connection=conn)
... schema = dj.Schema('my_schema', connection=conn)
... # perform operations
... # connection automatically closed
"""
Expand Down
2 changes: 1 addition & 1 deletion src/datajoint/declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def substitute_special_type(match: dict, category: str, foreign_key_sql: list[st
match["type"] = sql_type
# else: type passes through as-is (json, date, datetime, char, varchar, enum)
else:
assert False, f"Unknown special type: {category}"
raise DataJointError(f"Unknown special type: {category}")


def compile_attribute(line: str, in_key: bool, foreign_key_sql: list[str], context: dict) -> tuple[str, str, str | None]:
Expand Down
6 changes: 3 additions & 3 deletions src/datajoint/diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
from matplotlib import pyplot as plt

plot_active = True
except:
except ImportError:
plot_active = False

try:
from networkx.drawing.nx_pydot import pydot_layout

diagram_active = True
except:
except ImportError:
diagram_active = False


Expand All @@ -48,7 +48,7 @@ class Diagram:

See Also
--------
https://docs.datajoint.com/core/datajoint-python/0.14/client/install/
https://docs.datajoint.com/how-to/installation/
"""

def __init__(self, *args, **kwargs) -> None:
Expand Down
10 changes: 5 additions & 5 deletions src/datajoint/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def fetch(self):

For single-row fetch, use fetch1() which is unchanged.

See migration guide: https://docs.datajoint.com/migration/fetch-api
See migration guide: https://docs.datajoint.com/how-to/migrate-from-0x/
"""
raise AttributeError(
"fetch() has been removed in DataJoint 2.0. "
Expand Down Expand Up @@ -1085,12 +1085,12 @@ def make_sql(self):
return "({sql1}) UNION ({sql2})".format(sql1=sql1, sql2=sql2)

def from_clause(self):
"""The union does not use a FROM clause"""
assert False
"""The union does not use a FROM clause."""
raise NotImplementedError("Union does not use a FROM clause")

def where_clause(self):
"""The union does not use a WHERE clause"""
assert False
"""The union does not use a WHERE clause."""
raise NotImplementedError("Union does not use a WHERE clause")

def __len__(self):
return self.connection.query(
Expand Down
15 changes: 0 additions & 15 deletions src/datajoint/hash.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/datajoint/heading.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ def _init_from_database(self) -> None:
except StopIteration:
if original_type.startswith("external"):
raise DataJointError(
f"Legacy datatype `{original_type}`. Migrate your external stores to datajoint 0.12: "
"https://docs.datajoint.io/python/admin/5-blob-config.html#migration-between-datajoint-v0-11-and-v0-12"
f"Legacy datatype `{original_type}`. See migration guide: "
"https://docs.datajoint.com/how-to/migrate-from-0x/"
)
# Not a special type - that's fine, could be native passthrough
category = None
Expand Down
Loading
Loading