Skip to content

Commit f28a3b9

Browse files
Merge pull request #1073 from guzman-raphael/remove-deprecated-features
Remove deprecated features + small fixes
2 parents d1059d6 + e0653b7 commit f28a3b9

32 files changed

+184
-713
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ docs/site
2929

3030

3131
!.vscode/settings.json
32+
!.vscode/launch.json
3233
!.devcontainer/devcontainer.json

.vscode/launch.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal",
13+
"justMyCode": false
14+
}
15+
]
16+
}

.vscode/settings.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77
"python.formatting.provider": "black",
88
"[python]": {
99
"editor.defaultFormatter": null
10-
}
10+
},
11+
"[markdown]": {
12+
"editor.defaultFormatter": "disable"
13+
},
14+
"files.autoSave": "off"
1115
}

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
- Added - Support for inserting data with CSV files - PR [#1067](https://github.com/datajoint/datajoint-python/pull/1067)
77
- Changed - Switch testing image from `pydev` to `djtest` PR [#1012](https://github.com/datajoint/datajoint-python/pull/1012)
88
- Added - DevContainer development environment compatible with GH Codespaces PR [1071](https://github.com/datajoint/datajoint-python/pull/1071)
9+
- Fixed - Convert lingering prints by replacing with logs PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
10+
- Changed - `table.progress()` defaults to no stdout PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
11+
- Changed - `table.describe()` defaults to no stdout PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
12+
- Deprecated - `table._update()` PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
13+
- Deprecated - old-style foreign key syntax PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
14+
- Deprecated - `dj.migrate_dj011_external_blob_storage_to_dj012()` PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
915

1016
### 0.13.8 -- Sep 21, 2022
1117
- Added - New documentation structure based on markdown PR [#1052](https://github.com/datajoint/datajoint-python/pull/1052)

LNX-docker-compose.yml

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PY_VER=3.8 MYSQL_VER=5.7 DISTRO=alpine MINIO_VER=RELEASE.2022-08-11T04-37-28Z HOST_UID=$(id -u) docker compose -f LNX-docker-compose.yml up --exit-code-from app --build
22
version: "2.4"
3-
x-net: &net
3+
x-net:
4+
&net
45
networks:
56
- main
67
services:
@@ -13,6 +14,11 @@ services:
1314
# - "3306:3306"
1415
# volumes:
1516
# - ./mysql/data:/var/lib/mysql
17+
healthcheck:
18+
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
19+
timeout: 30s
20+
retries: 5
21+
interval: 15s
1622
minio:
1723
<<: *net
1824
image: minio/minio:${MINIO_VER}
@@ -26,10 +32,16 @@ services:
2632
# - ./minio/data:/data
2733
command: server --address ":9000" /data
2834
healthcheck:
29-
test: ["CMD", "curl", "--fail", "http://minio:9000/minio/health/live"]
30-
timeout: 5s
31-
retries: 60
32-
interval: 1s
35+
test:
36+
[
37+
"CMD",
38+
"curl",
39+
"--fail",
40+
"http://minio:9000/minio/health/live"
41+
]
42+
timeout: 30s
43+
retries: 5
44+
interval: 15s
3345
fakeservices.datajoint.io:
3446
<<: *net
3547
image: datajoint/nginx:v0.2.4

datajoint/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"key",
5252
"key_hash",
5353
"logger",
54-
"migrate_dj011_external_blob_storage_to_dj012",
5554
]
5655

5756
from .logging import logger
@@ -71,7 +70,6 @@
7170
from .attribute_adapter import AttributeAdapter
7271
from . import errors
7372
from .errors import DataJointError
74-
from .migrate import migrate_dj011_external_blob_storage_to_dj012
7573

7674
ERD = Di = Diagram # Aliases for Diagram
7775
schema = Schema # Aliases for Schema

datajoint/admin.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from .connection import conn
44
from .settings import config
55
from .utils import user_choice
6+
import logging
7+
8+
logger = logging.getLogger(__name__.split(".")[0])
69

710

811
def set_password(
@@ -13,10 +16,10 @@ def set_password(
1316
new_password = getpass("New password: ")
1417
confirm_password = getpass("Confirm password: ")
1518
if new_password != confirm_password:
16-
print("Failed to confirm the password! Aborting password change.")
19+
logger.warn("Failed to confirm the password! Aborting password change.")
1720
return
1821
connection.query("SET PASSWORD = PASSWORD('%s')" % new_password)
19-
print("Password updated.")
22+
logger.info("Password updated.")
2023

2124
if update_config or (
2225
update_config is None and user_choice("Update local setting?") == "yes"
@@ -81,7 +84,7 @@ def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
8184
try:
8285
connection.query("kill %d" % pid)
8386
except pymysql.err.InternalError:
84-
print("Process not found")
87+
logger.warn("Process not found")
8588

8689

8790
def kill_quick(restriction=None, connection=None):

datajoint/autopopulate.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _populate1(
325325
finally:
326326
self.__class__._allow_insert = False
327327

328-
def progress(self, *restrictions, display=True):
328+
def progress(self, *restrictions, display=False):
329329
"""
330330
Report the progress of populating the table.
331331
:return: (remaining, total) -- numbers of tuples to be populated
@@ -334,9 +334,9 @@ def progress(self, *restrictions, display=True):
334334
total = len(todo)
335335
remaining = len(todo - self.target)
336336
if display:
337-
print(
338-
"%-20s" % self.__class__.__name__,
339-
"Completed %d of %d (%2.1f%%) %s"
337+
logger.info(
338+
"%-20s" % self.__class__.__name__
339+
+ " Completed %d of %d (%2.1f%%) %s"
340340
% (
341341
total - remaining,
342342
total,
@@ -345,6 +345,5 @@ def progress(self, *restrictions, display=True):
345345
datetime.datetime.now(), "%Y-%m-%d %H:%M:%S"
346346
),
347347
),
348-
flush=True,
349348
)
350349
return remaining, total

datajoint/declare.py

+4-70
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,14 @@ def compile_foreign_key(
177177
from .table import Table
178178
from .expression import QueryExpression
179179

180-
obsolete = False # See issue #436. Old style to be deprecated in a future release
181180
try:
182181
result = foreign_key_parser.parseString(line)
183-
except pp.ParseException:
184-
try:
185-
result = foreign_key_parser_old.parseString(line)
186-
except pp.ParseBaseException as err:
187-
raise DataJointError('Parsing error in line "%s". %s.' % (line, err))
188-
else:
189-
obsolete = True
182+
except pp.ParseException as err:
183+
raise DataJointError('Parsing error in line "%s". %s.' % (line, err))
184+
190185
try:
191186
ref = eval(result.ref_table, context)
192-
except NameError if obsolete else Exception:
187+
except Exception:
193188
raise DataJointError(
194189
"Foreign key reference %s could not be resolved" % result.ref_table
195190
)
@@ -205,18 +200,6 @@ def compile_foreign_key(
205200
'Primary dependencies cannot be nullable in line "{line}"'.format(line=line)
206201
)
207202

208-
if obsolete:
209-
logger.warning(
210-
'Line "{line}" uses obsolete syntax that will no longer be supported in datajoint 0.14. '
211-
"For details, see issue #780 https://github.com/datajoint/datajoint-python/issues/780".format(
212-
line=line
213-
)
214-
)
215-
if not isinstance(ref, type) or not issubclass(ref, Table):
216-
raise DataJointError(
217-
"Foreign key reference %r must be a valid query" % result.ref_table
218-
)
219-
220203
if isinstance(ref, type) and issubclass(ref, Table):
221204
ref = ref()
222205

@@ -232,55 +215,6 @@ def compile_foreign_key(
232215
% result.ref_table
233216
)
234217

235-
if obsolete:
236-
# for backward compatibility with old-style dependency declarations. See issue #436
237-
if not isinstance(ref, Table):
238-
DataJointError(
239-
'Dependency "%s" is not supported. Check documentation.'
240-
% result.ref_table
241-
)
242-
if not all(r in ref.primary_key for r in result.ref_attrs):
243-
raise DataJointError('Invalid foreign key attributes in "%s"' % line)
244-
try:
245-
raise DataJointError(
246-
'Duplicate attributes "{attr}" in "{line}"'.format(
247-
attr=next(attr for attr in result.new_attrs if attr in attributes),
248-
line=line,
249-
)
250-
)
251-
except StopIteration:
252-
pass # the normal outcome
253-
254-
# Match the primary attributes of the referenced table to local attributes
255-
new_attrs = list(result.new_attrs)
256-
ref_attrs = list(result.ref_attrs)
257-
258-
# special case, the renamed attribute is implicit
259-
if new_attrs and not ref_attrs:
260-
if len(new_attrs) != 1:
261-
raise DataJointError(
262-
'Renamed foreign key must be mapped to the primary key in "%s"'
263-
% line
264-
)
265-
if len(ref.primary_key) == 1:
266-
# if the primary key has one attribute, allow implicit renaming
267-
ref_attrs = ref.primary_key
268-
else:
269-
# if only one primary key attribute remains, then allow implicit renaming
270-
ref_attrs = [attr for attr in ref.primary_key if attr not in attributes]
271-
if len(ref_attrs) != 1:
272-
raise DataJointError(
273-
'Could not resolve which primary key attribute should be referenced in "%s"'
274-
% line
275-
)
276-
277-
if len(new_attrs) != len(ref_attrs):
278-
raise DataJointError('Mismatched attributes in foreign key "%s"' % line)
279-
280-
if ref_attrs:
281-
# convert to projected dependency
282-
ref = ref.proj(**dict(zip(new_attrs, ref_attrs)))
283-
284218
# declare new foreign key attributes
285219
for attr in ref.primary_key:
286220
if attr not in attributes:

datajoint/diagram.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,7 @@ def make_dot(self):
383383
if name.split(".")[0] in self.context:
384384
cls = eval(name, self.context)
385385
assert issubclass(cls, Table)
386-
description = (
387-
cls().describe(context=self.context, printout=False).split("\n")
388-
)
386+
description = cls().describe(context=self.context).split("\n")
389387
description = (
390388
"-" * 30
391389
if q.startswith("---")

0 commit comments

Comments
 (0)