Skip to content

Commit 477d365

Browse files
chore: Remove unused settings
Remove dead code: - filepath_checksum_size_limit (never used) - enable_python_native_blobs (never used) - cache (only query_cache is used) - init_function/init_command (database init command) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7196705 commit 477d365

File tree

5 files changed

+17
-38
lines changed

5 files changed

+17
-38
lines changed

src/datajoint/adapters/mysql.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def connect(
7575
Password for authentication.
7676
**kwargs : Any
7777
Additional MySQL-specific parameters:
78-
- init_command: SQL initialization command
7978
- ssl: TLS/SSL configuration dict (deprecated, use use_tls)
8079
- use_tls: bool or dict - DataJoint's SSL parameter (preferred)
8180
- charset: Character set (default from kwargs)
@@ -85,7 +84,6 @@ def connect(
8584
pymysql.Connection
8685
MySQL connection object.
8786
"""
88-
init_command = kwargs.get("init_command")
8987
# Handle both ssl (old) and use_tls (new) parameter names
9088
ssl_config = kwargs.get("use_tls", kwargs.get("ssl"))
9189
# Convert boolean True to dict for PyMySQL (PyMySQL expects dict or SSLContext)
@@ -99,7 +97,6 @@ def connect(
9997
"port": port,
10098
"user": user,
10199
"passwd": password,
102-
"init_command": init_command,
103100
"sql_mode": "NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,"
104101
"STRICT_ALL_TABLES,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY",
105102
"charset": charset,

src/datajoint/connection.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def conn(
5555
user: str | None = None,
5656
password: str | None = None,
5757
*,
58-
init_fun: Callable | None = None,
5958
reset: bool = False,
6059
use_tls: bool | dict | None = None,
6160
) -> Connection:
@@ -73,8 +72,6 @@ def conn(
7372
Database username. Required if not set in config.
7473
password : str, optional
7574
Database password. Required if not set in config.
76-
init_fun : callable, optional
77-
Initialization function called after connection.
7875
reset : bool, optional
7976
If True, reset existing connection. Default False.
8077
use_tls : bool or dict, optional
@@ -103,9 +100,8 @@ def conn(
103100
raise errors.DataJointError(
104101
"Database password not configured. Set datajoint.config['database.password'] or pass password= argument."
105102
)
106-
init_fun = init_fun if init_fun is not None else config["connection.init_function"]
107103
use_tls = use_tls if use_tls is not None else config["database.use_tls"]
108-
conn.connection = Connection(host, user, password, None, init_fun, use_tls)
104+
conn.connection = Connection(host, user, password, None, use_tls)
109105
return conn.connection
110106

111107

@@ -150,8 +146,6 @@ class Connection:
150146
Database password.
151147
port : int, optional
152148
Port number. Overridden if specified in host.
153-
init_fun : str, optional
154-
SQL initialization command.
155149
use_tls : bool or dict, optional
156150
TLS encryption option.
157151
@@ -169,7 +163,6 @@ def __init__(
169163
user: str,
170164
password: str,
171165
port: int | None = None,
172-
init_fun: str | None = None,
173166
use_tls: bool | dict | None = None,
174167
) -> None:
175168
if ":" in host:
@@ -190,7 +183,6 @@ def __init__(
190183
# use_tls=True: enable SSL with default settings
191184
self.conn_info["ssl"] = True
192185
self.conn_info["ssl_input"] = use_tls
193-
self.init_fun = init_fun
194186
self._conn = None
195187
self._query_cache = None
196188
self._is_closed = True # Mark as closed until connect() succeeds
@@ -227,7 +219,6 @@ def connect(self) -> None:
227219
port=self.conn_info["port"],
228220
user=self.conn_info["user"],
229221
password=self.conn_info["passwd"],
230-
init_command=self.init_fun,
231222
charset=config["connection.charset"],
232223
use_tls=self.conn_info.get("ssl"),
233224
)
@@ -244,7 +235,6 @@ def connect(self) -> None:
244235
port=self.conn_info["port"],
245236
user=self.conn_info["user"],
246237
password=self.conn_info["passwd"],
247-
init_command=self.init_fun,
248238
charset=config["connection.charset"],
249239
use_tls=False, # Explicitly disable SSL for fallback
250240
)

src/datajoint/settings.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ class ConnectionSettings(BaseSettings):
224224

225225
model_config = SettingsConfigDict(extra="forbid", validate_assignment=True)
226226

227-
init_function: str | None = None
228227
charset: str = "" # pymysql uses '' as default
229228

230229

@@ -341,11 +340,8 @@ class Config(BaseSettings):
341340
# Top-level settings
342341
loglevel: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = Field(default="INFO", validation_alias="DJ_LOG_LEVEL")
343342
safemode: bool = True
344-
enable_python_native_blobs: bool = True
345-
filepath_checksum_size_limit: int | None = None
346343

347-
# Cache paths
348-
cache: Path | None = None
344+
# Cache path for query results
349345
query_cache: Path | None = None
350346

351347
# Download path for attachments and filepaths
@@ -362,7 +358,7 @@ def set_logger_level(cls, v: str) -> str:
362358
logger.setLevel(v)
363359
return v
364360

365-
@field_validator("cache", "query_cache", mode="before")
361+
@field_validator("query_cache", mode="before")
366362
@classmethod
367363
def convert_path(cls, v: Any) -> Path | None:
368364
"""Convert string paths to Path objects."""
@@ -819,7 +815,6 @@ def save_template(
819815
"use_tls": None,
820816
},
821817
"connection": {
822-
"init_function": None,
823818
"charset": "",
824819
},
825820
"display": {
@@ -844,8 +839,6 @@ def save_template(
844839
},
845840
"loglevel": "INFO",
846841
"safemode": True,
847-
"enable_python_native_blobs": True,
848-
"cache": None,
849842
"query_cache": None,
850843
"download_path": ".",
851844
}

tests/integration/test_jobs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ def test_sigterm(clean_jobs, schema_any):
108108

109109

110110
def test_suppress_dj_errors(clean_jobs, schema_any):
111-
"""Test that DataJoint errors are suppressible without native py blobs."""
111+
"""Test that DataJoint errors are suppressible."""
112112
error_class = schema.ErrorClass()
113-
with dj.config.override(enable_python_native_blobs=False):
114-
error_class.populate(reserve_jobs=True, suppress_errors=True)
113+
error_class.populate(reserve_jobs=True, suppress_errors=True)
115114
assert len(schema.DjExceptionName()) == len(error_class.jobs.errors) > 0
116115

117116

tests/unit/test_settings.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,23 +504,23 @@ def test_display_limit(self):
504504
class TestCachePaths:
505505
"""Test cache path settings."""
506506

507-
def test_cache_path_string(self):
508-
"""Test setting cache path as string."""
509-
original = dj.config.cache
507+
def test_query_cache_path_string(self):
508+
"""Test setting query_cache path as string."""
509+
original = dj.config.query_cache
510510
try:
511-
dj.config.cache = "/tmp/cache"
512-
assert dj.config.cache == Path("/tmp/cache")
511+
dj.config.query_cache = "/tmp/cache"
512+
assert dj.config.query_cache == Path("/tmp/cache")
513513
finally:
514-
dj.config.cache = original
514+
dj.config.query_cache = original
515515

516-
def test_cache_path_none(self):
517-
"""Test cache path can be None."""
518-
original = dj.config.cache
516+
def test_query_cache_path_none(self):
517+
"""Test query_cache path can be None."""
518+
original = dj.config.query_cache
519519
try:
520-
dj.config.cache = None
521-
assert dj.config.cache is None
520+
dj.config.query_cache = None
521+
assert dj.config.query_cache is None
522522
finally:
523-
dj.config.cache = original
523+
dj.config.query_cache = original
524524

525525

526526
class TestSaveTemplate:

0 commit comments

Comments
 (0)