Skip to content

Commit b13ffda

Browse files
author
Chris Turner
authored
Merge pull request #474 from dimitri-yatsenko/master
update release info for version 0.10.1
2 parents 49a93a7 + 64c9e94 commit b13ffda

File tree

11 files changed

+165
-81
lines changed

11 files changed

+165
-81
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
## Release notes
2-
### 0.10.1 -- Work in progress
2+
### 0.10.1
3+
* Fix ERD Tooltip message (#431)
34
* Networkx 2.0 support (#443)
4-
* Sped up queries (#428)
5+
* Fix insert from query with skip_duplicates=True (#451)
6+
* Sped up queries (#458)
7+
* Bugfix in restriction of the form (A & B) * B (#463)
8+
* Improved error messages (#466)
59

610
### 0.10.0 -- January 10, 2018
711
* Deletes are more efficient (#424)

datajoint/__init__.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""
2-
DataJoint for Python is a high-level programming interface for MySQL databases
3-
to support data processing chains in science labs. DataJoint is built on the
4-
foundation of the relational data model and prescribes a consistent method for
5-
organizing, populating, and querying data.
2+
DataJoint for Python is a framework for building data piplines using MySQL databases
3+
to represent pipeline structure and bulk storage systems for large objects.
4+
DataJoint is built on the foundation of the relational data model and prescribes a
5+
consistent method for organizing, populating, and querying data.
6+
7+
The DataJoint data model is described in https://arxiv.org/abs/1807.11104
68
79
DataJoint is free software under the LGPL License. In addition, we request
810
that any use of DataJoint leading to a publication be acknowledged in the publication.
@@ -18,7 +20,7 @@
1820
from .version import __version__
1921

2022
__author__ = "Dimitri Yatsenko, Edgar Y. Walker, and Fabian Sinz at Baylor College of Medicine"
21-
__date__ = "July 26, 2017"
23+
__date__ = "August 24, 2018"
2224
__all__ = ['__author__', '__version__',
2325
'config', 'conn', 'kill', 'BaseRelation',
2426
'Connection', 'Heading', 'FreeRelation', 'Not', 'schema',
@@ -71,17 +73,19 @@ class key:
7173
from .errors import DataJointError, DuplicateError
7274

7375

74-
def create_virtual_module(modulename, dbname):
76+
def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False):
7577
"""
76-
Creates a python module with the given name from a database name in mysql with datajoint tables.
77-
Automatically creates the classes of the appropriate tier in the module.
78+
Creates a python module with the given name from the name of a schema on the server and
79+
automatically adds classes to it corresponding to the tables in the schema.
7880
79-
:param modulename: desired name of the module
80-
:param dbname: name of the database in mysql
81-
:return: the python module
81+
:param module_name: displayed module name
82+
:param schema_name: name of the database in mysql
83+
:param create_schema: if True, create the schema on the database server
84+
:param create_tables: if True, module.schema can be used as the decorator for declaring new
85+
:return: the python module containing classes from the schema object and the table classes
8286
"""
83-
mod = ModuleType(modulename)
84-
s = schema(dbname, mod.__dict__)
85-
s.spawn_missing_classes()
86-
mod.__dict__['schema'] = s
87-
return mod
87+
module = ModuleType(module_name)
88+
_schema = schema(schema_name, create_schema=create_schema, create_tables=create_tables)
89+
_schema.spawn_missing_classes(context=module.__dict__)
90+
module.__dict__['schema'] = _schema
91+
return module

datajoint/base_relation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class BaseRelation(RelationalOperand):
2323
"""
24-
BaseRelation is an abstract class that represents a base relation, i.e. a table in the database.
24+
BaseRelation is an abstract class that represents a base relation, i.e. a table in the schema.
2525
To make it a concrete class, override the abstract properties specifying the connection,
2626
table name, database, context, and definition.
2727
A Relation implements insert and delete methods in addition to inherited relational operators.
@@ -56,7 +56,7 @@ def context(self):
5656

5757
def declare(self):
5858
"""
59-
Use self.definition to declare the table in the database
59+
Use self.definition to declare the table in the schema.
6060
"""
6161
try:
6262
sql, uses_external = declare(self.full_table_name, self.definition, self._context)
@@ -108,7 +108,7 @@ def children(self, primary=None):
108108
@property
109109
def is_declared(self):
110110
"""
111-
:return: True is the table is declared in the database
111+
:return: True is the table is declared in the schema.
112112
"""
113113
return self.connection.query(
114114
'SHOW TABLES in `{database}` LIKE "{table_name}"'.format(
@@ -117,7 +117,7 @@ def is_declared(self):
117117
@property
118118
def full_table_name(self):
119119
"""
120-
:return: full table name in the database
120+
:return: full table name in the schema
121121
"""
122122
return r"`{0:s}`.`{1:s}`".format(self.database, self.table_name)
123123

@@ -541,8 +541,8 @@ def _update(self, attrname, value=None):
541541

542542
def lookup_class_name(name, context, depth=3):
543543
"""
544-
given a table name in the form `database`.`table_name`, find its class in the context.
545-
:param name: `database`.`table_name`
544+
given a table name in the form `schema_name`.`table_name`, find its class in the context.
545+
:param name: `schema_name`.`table_name`
546546
:param context: dictionary representing the namespace
547547
:param depth: search depth into imported modules, helps avoid infinite recursion.
548548
:return: class name found in the context or None if not found
@@ -599,14 +599,14 @@ def __repr__(self):
599599
@property
600600
def table_name(self):
601601
"""
602-
:return: the table name in the database
602+
:return: the table name in the schema
603603
"""
604604
return self._table_name
605605

606606

607607
class Log(BaseRelation):
608608
"""
609-
The log table for each database.
609+
The log table for each schema.
610610
Instances are callable. Calls log the time and identifying information along with the event.
611611
"""
612612

datajoint/connection.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This module hosts the Connection class that manages the connection to the mysql database,
2+
This module hosts the Connection class that manages the connection to the database,
33
and the `conn` function that provides access to a persistent connection in datajoint.
44
"""
55
import warnings
@@ -92,11 +92,12 @@ def connect(self):
9292
"""
9393
with warnings.catch_warnings():
9494
warnings.filterwarnings('ignore', '.*deprecated.*')
95-
self._conn = client.connect(init_command=self.init_fun,
96-
sql_mode="NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,"
97-
"STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION",
98-
charset=config['connection.charset'],
99-
**self.conn_info)
95+
self._conn = client.connect(
96+
init_command=self.init_fun,
97+
sql_mode="NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,"
98+
"STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION",
99+
charset=config['connection.charset'],
100+
**self.conn_info)
100101

101102
def register(self, schema):
102103
self.schemas[schema.database] = schema

datajoint/erd.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,31 @@ 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+
200225
def _make_graph(self):
201226
"""
202227
Make the self.graph - a graph object ready for drawing

datajoint/fetch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def to_dicts(recarray):
1919

2020
class Fetch:
2121
"""
22-
A fetch object that handles retrieving elements from the database table.
23-
:param relation: relation the fetch object fetches data from
22+
A fetch object that handles retrieving elements from the table expression.
23+
:param relation: the table expression to fetch from
2424
"""
2525

2626
def __init__(self, relation):

datajoint/relational_operand.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def heading(self):
9494

9595
@property
9696
def distinct(self):
97-
"""True if the DISTINCT modifier is required to turn the query into a relation"""
97+
"""
98+
:return: True if the DISTINCT modifier is required to make valid result
99+
"""
98100
return self._distinct
99101

100102
@property

0 commit comments

Comments
 (0)