Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ docs/site


!.vscode/settings.json
!.vscode/launch.json
!.devcontainer/devcontainer.json
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
"python.formatting.provider": "black",
"[python]": {
"editor.defaultFormatter": null
}
},
"[markdown]": {
"editor.defaultFormatter": "disable"
},
"files.autoSave": "off"
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
- Added - Support for inserting data with CSV files - PR [#1067](https://github.com/datajoint/datajoint-python/pull/1067)
- Changed - Switch testing image from `pydev` to `djtest` PR [#1012](https://github.com/datajoint/datajoint-python/pull/1012)
- Added - DevContainer development environment compatible with GH Codespaces PR [1071](https://github.com/datajoint/datajoint-python/pull/1071)
- Fixed - Convert lingering prints by replacing with logs PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
- Changed - `table.progress()` defaults to no stdout PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
- Changed - `table.describe()` defaults to no stdout PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
- Deprecated - `table._update()` PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
- Deprecated - old-style foreign key syntax PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)
- Deprecated - `dj.migrate_dj011_external_blob_storage_to_dj012()` PR [#1073](https://github.com/datajoint/datajoint-python/pull/1073)

### 0.13.8 -- Sep 21, 2022
- Added - New documentation structure based on markdown PR [#1052](https://github.com/datajoint/datajoint-python/pull/1052)
Expand Down
22 changes: 17 additions & 5 deletions LNX-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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
version: "2.4"
x-net: &net
x-net:
&net
networks:
- main
services:
Expand All @@ -13,6 +14,11 @@ services:
# - "3306:3306"
# volumes:
# - ./mysql/data:/var/lib/mysql
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
timeout: 30s
retries: 5
interval: 15s
minio:
<<: *net
image: minio/minio:${MINIO_VER}
Expand All @@ -26,10 +32,16 @@ services:
# - ./minio/data:/data
command: server --address ":9000" /data
healthcheck:
test: ["CMD", "curl", "--fail", "http://minio:9000/minio/health/live"]
timeout: 5s
retries: 60
interval: 1s
test:
[
"CMD",
"curl",
"--fail",
"http://minio:9000/minio/health/live"
]
timeout: 30s
retries: 5
interval: 15s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.2.4
Expand Down
2 changes: 0 additions & 2 deletions datajoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"key",
"key_hash",
"logger",
"migrate_dj011_external_blob_storage_to_dj012",
]

from .logging import logger
Expand All @@ -71,7 +70,6 @@
from .attribute_adapter import AttributeAdapter
from . import errors
from .errors import DataJointError
from .migrate import migrate_dj011_external_blob_storage_to_dj012

ERD = Di = Diagram # Aliases for Diagram
schema = Schema # Aliases for Schema
Expand Down
9 changes: 6 additions & 3 deletions datajoint/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from .connection import conn
from .settings import config
from .utils import user_choice
import logging

logger = logging.getLogger(__name__.split(".")[0])


def set_password(
Expand All @@ -13,10 +16,10 @@ def set_password(
new_password = getpass("New password: ")
confirm_password = getpass("Confirm password: ")
if new_password != confirm_password:
print("Failed to confirm the password! Aborting password change.")
logger.warn("Failed to confirm the password! Aborting password change.")
return
connection.query("SET PASSWORD = PASSWORD('%s')" % new_password)
print("Password updated.")
logger.info("Password updated.")

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


def kill_quick(restriction=None, connection=None):
Expand Down
9 changes: 4 additions & 5 deletions datajoint/autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _populate1(
finally:
self.__class__._allow_insert = False

def progress(self, *restrictions, display=True):
def progress(self, *restrictions, display=False):
"""
Report the progress of populating the table.
:return: (remaining, total) -- numbers of tuples to be populated
Expand All @@ -334,9 +334,9 @@ def progress(self, *restrictions, display=True):
total = len(todo)
remaining = len(todo - self.target)
if display:
print(
"%-20s" % self.__class__.__name__,
"Completed %d of %d (%2.1f%%) %s"
logger.info(
"%-20s" % self.__class__.__name__
+ " Completed %d of %d (%2.1f%%) %s"
% (
total - remaining,
total,
Expand All @@ -345,6 +345,5 @@ def progress(self, *restrictions, display=True):
datetime.datetime.now(), "%Y-%m-%d %H:%M:%S"
),
),
flush=True,
)
return remaining, total
74 changes: 4 additions & 70 deletions datajoint/declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,14 @@ def compile_foreign_key(
from .table import Table
from .expression import QueryExpression

obsolete = False # See issue #436. Old style to be deprecated in a future release
try:
result = foreign_key_parser.parseString(line)
except pp.ParseException:
try:
result = foreign_key_parser_old.parseString(line)
except pp.ParseBaseException as err:
raise DataJointError('Parsing error in line "%s". %s.' % (line, err))
else:
obsolete = True
except pp.ParseException as err:
raise DataJointError('Parsing error in line "%s". %s.' % (line, err))

try:
ref = eval(result.ref_table, context)
except NameError if obsolete else Exception:
except Exception:
raise DataJointError(
"Foreign key reference %s could not be resolved" % result.ref_table
)
Expand All @@ -205,18 +200,6 @@ def compile_foreign_key(
'Primary dependencies cannot be nullable in line "{line}"'.format(line=line)
)

if obsolete:
logger.warning(
'Line "{line}" uses obsolete syntax that will no longer be supported in datajoint 0.14. '
"For details, see issue #780 https://github.com/datajoint/datajoint-python/issues/780".format(
line=line
)
)
if not isinstance(ref, type) or not issubclass(ref, Table):
raise DataJointError(
"Foreign key reference %r must be a valid query" % result.ref_table
)

if isinstance(ref, type) and issubclass(ref, Table):
ref = ref()

Expand All @@ -232,55 +215,6 @@ def compile_foreign_key(
% result.ref_table
)

if obsolete:
# for backward compatibility with old-style dependency declarations. See issue #436
if not isinstance(ref, Table):
DataJointError(
'Dependency "%s" is not supported. Check documentation.'
% result.ref_table
)
if not all(r in ref.primary_key for r in result.ref_attrs):
raise DataJointError('Invalid foreign key attributes in "%s"' % line)
try:
raise DataJointError(
'Duplicate attributes "{attr}" in "{line}"'.format(
attr=next(attr for attr in result.new_attrs if attr in attributes),
line=line,
)
)
except StopIteration:
pass # the normal outcome

# Match the primary attributes of the referenced table to local attributes
new_attrs = list(result.new_attrs)
ref_attrs = list(result.ref_attrs)

# special case, the renamed attribute is implicit
if new_attrs and not ref_attrs:
if len(new_attrs) != 1:
raise DataJointError(
'Renamed foreign key must be mapped to the primary key in "%s"'
% line
)
if len(ref.primary_key) == 1:
# if the primary key has one attribute, allow implicit renaming
ref_attrs = ref.primary_key
else:
# if only one primary key attribute remains, then allow implicit renaming
ref_attrs = [attr for attr in ref.primary_key if attr not in attributes]
if len(ref_attrs) != 1:
raise DataJointError(
'Could not resolve which primary key attribute should be referenced in "%s"'
% line
)

if len(new_attrs) != len(ref_attrs):
raise DataJointError('Mismatched attributes in foreign key "%s"' % line)

if ref_attrs:
# convert to projected dependency
ref = ref.proj(**dict(zip(new_attrs, ref_attrs)))

# declare new foreign key attributes
for attr in ref.primary_key:
if attr not in attributes:
Expand Down
4 changes: 1 addition & 3 deletions datajoint/diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ def make_dot(self):
if name.split(".")[0] in self.context:
cls = eval(name, self.context)
assert issubclass(cls, Table)
description = (
cls().describe(context=self.context, printout=False).split("\n")
)
description = cls().describe(context=self.context).split("\n")
description = (
"-" * 30
if q.startswith("---")
Expand Down
Loading