Skip to content

Commit 1b2827a

Browse files
authored
Merge pull request #517 from dimitri-yatsenko/master
Fix issues #483, #516, and #518
2 parents 9fdecfe + bae0900 commit 1b2827a

27 files changed

+330
-366
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Release notes
22

3+
### 0.11.1 -- Nov 15, 2018
4+
* Fix ordering of attributes in proj (#483 and #516)
5+
* Prohibit direct insert into auto-populated tables (#511)
6+
37
### 0.11.0 -- Oct 25, 2018
48
* Full support of dependencies with renamed attributes using projection syntax (#300, #345, #436, #506, #507)
59
* Rename internal class and module names to comply with terminology in documentation (#494, #500)

datajoint/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
"""
1616

1717
import os
18-
from types import ModuleType
1918
from .version import __version__
2019

2120
__author__ = "Dimitri Yatsenko, Edgar Y. Walker, and Fabian Sinz at Baylor College of Medicine"
22-
__date__ = "Oct 25, 2018"
21+
__date__ = "Nov 15, 2018"
2322
__all__ = ['__author__', '__version__',
2423
'config', 'conn', 'kill', 'Table',
2524
'Connection', 'Heading', 'FreeTable', 'Not', 'schema',
@@ -68,15 +67,15 @@ class key:
6867
from .connection import conn, Connection
6968
from .table import FreeTable, Table
7069
from .user_tables import Manual, Lookup, Imported, Computed, Part
71-
from .query import Not, AndList, U
70+
from .expression import Not, AndList, U
7271
from .heading import Heading
7372
from .schema import Schema as schema
7473
from .erd import ERD
7574
from .admin import set_password, kill
7675
from .errors import DataJointError, DuplicateError
7776

7877

79-
def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False):
78+
def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False, connection=None):
8079
"""
8180
Creates a python module with the given name from the name of a schema on the server and
8281
automatically adds classes to it corresponding to the tables in the schema.
@@ -87,8 +86,9 @@ def create_virtual_module(module_name, schema_name, create_schema=False, create_
8786
:param create_tables: if True, module.schema can be used as the decorator for declaring new
8887
:return: the python module containing classes from the schema object and the table classes
8988
"""
90-
module = ModuleType(module_name)
91-
_schema = schema(schema_name, create_schema=create_schema, create_tables=create_tables)
89+
import types
90+
module = types.ModuleType(module_name)
91+
_schema = schema(schema_name, create_schema=create_schema, create_tables=create_tables, connection=connection)
9292
_schema.spawn_missing_classes(context=module.__dict__)
9393
module.__dict__['schema'] = _schema
9494
return module

datajoint/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def kill(restriction=None, connection=None): # pragma: no cover
4343
while True:
4444
print(' ID USER STATE TIME INFO')
4545
print('+--+ +----------+ +-----------+ +--+')
46-
for process in connection.query(query, as_dict=True).fetchall():
46+
cur = connection.query(query, as_dict=True)
47+
for process in cur:
4748
try:
4849
print('{ID:>4d} {USER:<12s} {STATE:<12s} {TIME:>5d} {INFO}'.format(**process))
4950
except TypeError:

datajoint/autopopulate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import random
66
from tqdm import tqdm
77
from pymysql import OperationalError
8-
from .query import Query, AndList, U
8+
from .expression import QueryExpression, AndList, U
99
from .errors import DataJointError
1010
from .table import FreeTable
1111
import signal
@@ -84,7 +84,7 @@ def _jobs_to_do(self, restrictions):
8484
raise DataJointError('Cannot call populate on a restricted table. '
8585
'Instead, pass conditions to populate() as arguments.')
8686
todo = self.key_source
87-
if not isinstance(todo, Query):
87+
if not isinstance(todo, QueryExpression):
8888
raise DataJointError('Invalid key_source value')
8989
# check if target lacks any attributes from the primary key of key_source
9090
try:

datajoint/declare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def compile_foreign_key(line, context, attributes, primary_key, attr_sql, foreig
9090
"""
9191
# Parse and validate
9292
from .table import Table
93-
from .query import Projection
93+
from .expression import Projection
9494

9595
new_style = True # See issue #436. Old style to be deprecated in a future release
9696
try:
@@ -194,7 +194,7 @@ def declare(full_table_name, definition, context):
194194
195195
:param full_table_name: full name of the table
196196
:param definition: DataJoint table definition
197-
:param context: dictionary of objects that might be referred to in the table. Usually this will be locals()
197+
:param context: dictionary of objects that might be referred to in the table.
198198
"""
199199
# split definition into lines
200200
definition = re.split(r'\s*\n\s*', definition.strip())

datajoint/erd.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -197,31 +197,6 @@ def __mul__(self, arg):
197197
self.nodes_to_show.intersection_update(arg.nodes_to_show)
198198
return self
199199

200-
def topological_sort(self):
201-
"""
202-
:return: list of nodes in topological order
203-
"""
204-
205-
def _unite(lst):
206-
"""
207-
reorder list so that parts immediately follow their masters without breaking the topological order.
208-
Without this correction, simple topological sort may insert other descendants between master and parts
209-
:example:
210-
_unite(['a', 'a__q', 'b', 'c', 'c__q', 'b__q', 'd', 'a__r'])
211-
-> ['a', 'a__q', 'a__r', 'b', 'b__q', 'c', 'c__q', 'd']
212-
"""
213-
if len(lst) <= 2:
214-
return lst
215-
el = lst.pop()
216-
lst = _unite(lst)
217-
if '__' in el:
218-
master = el.split('__')[0]
219-
if not lst[-1].startswith(master):
220-
return _unite(lst[:-1] + [el, lst[-1]])
221-
return lst + [el]
222-
223-
return _unite(list(nx.algorithms.dag.topological_sort(self.subgraph(self.nodes_to_show))))
224-
225200
def _make_graph(self):
226201
"""
227202
Make the self.graph - a graph object ready for drawing

0 commit comments

Comments
 (0)