Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
701bf76
fix #483 and #516: .proj() preserves original order. Also rename cla…
dimitri-yatsenko Nov 13, 2018
38f1dba
Merge branch 'dev'
dimitri-yatsenko Nov 13, 2018
08e61e6
complete renaming query -> expression
dimitri-yatsenko Nov 13, 2018
025dd93
rename class Expression -> QueryExpression
dimitri-yatsenko Nov 13, 2018
1d5b593
add test for create_virtual_module and for issue #516
dimitri-yatsenko Nov 13, 2018
f0c8b8f
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko Nov 13, 2018
a348758
fix doc strings to use QueryExpression
dimitri-yatsenko Nov 13, 2018
8edb4d7
add test for QueryExpression iterator
dimitri-yatsenko Nov 13, 2018
85dca73
finish renaming query -> expression in fetch.py
dimitri-yatsenko Nov 13, 2018
470682a
update version and CHANGELOG for release 0.11.1
dimitri-yatsenko Nov 13, 2018
65ea0e7
minor
dimitri-yatsenko Nov 13, 2018
8cca325
minor
dimitri-yatsenko Nov 14, 2018
77644ee
increase timeout for nosetests in travis
dimitri-yatsenko Nov 14, 2018
b46b64b
change terminology from `relations` to `query expressions` in doc str…
dimitri-yatsenko Nov 14, 2018
277398f
undo travis setting -- travis still not working on GitHub
dimitri-yatsenko Nov 16, 2018
06d5cc3
undo inconsequential change from previous commit to try to figure out…
dimitri-yatsenko Nov 16, 2018
10f7393
simplify context management, move test initialization into setup_clas…
dimitri-yatsenko Nov 17, 2018
29ca4c9
remove make_module_code for lack of potential use, tagging this commi…
dimitri-yatsenko Nov 17, 2018
bae0900
remove erd.topological_sort -- it is never called
dimitri-yatsenko Nov 17, 2018
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
Prev Previous commit
Next Next commit
remove make_module_code for lack of potential use, tagging this commi…
…t with "make_module_code"
  • Loading branch information
dimitri-yatsenko committed Nov 17, 2018
commit 29ca4c9dfb138cbf9a68752526c0d4a7c4594da0
42 changes: 0 additions & 42 deletions datajoint/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,48 +100,6 @@ def size_on_disk(self):
FROM information_schema.tables WHERE table_schema='{db}'
""".format(db=self.database)).fetchone()[0])

def _make_module_code(self):
"""
Generate the code to recreate the schema as a module.
This method is in preparation for a future release and is not officially supported.
:return: a string containing the body of a complete Python module defining this schema.
"""

module_count = itertools.count()
# add virtual modules for referenced modules with names vmod0, vmod1, ...
module_lookup = collections.defaultdict(lambda: 'vmod' + str(next(module_count)))
db = self.database

def make_class_definition(table):
tier = _get_tier(table).__name__
class_name = table.split('.')[1].strip('`')
indent = ''
if tier == 'Part':
class_name = class_name.split('__')[1]
indent += ' '
class_name = to_camel_case(class_name)

def repl(s):
d, tab = s.group(1), s.group(2)
return ('' if d == db else (module_lookup[d]+'.')) + to_camel_case(tab)

return ('' if tier == 'Part' else '@schema\n') + \
'{indent}class {class_name}(dj.{tier}):\n{indent} definition = """\n{indent} {defi}"""'.format(
class_name=class_name,
indent=indent,
tier=tier,
defi=re.sub(
r'`([^`]+)`.`([^`]+)`', repl,
FreeTable(self.connection, table).describe(printout=False).replace('\n', '\n ' + indent)))

erd = ERD(self)
body = '\n\n\n'.join(make_class_definition(table) for table in erd.topological_sort())
return '\n\n\n'.join((
'"""This module was auto-generated by datajoint from an existing schema"""',
"import datajoint as dj\n\nschema = dj.schema('{db}')".format(db=db),
'\n'.join("{module} = dj.create_virtual_module('{module}', '{schema_name}')".format(module=v, schema_name=k)
for k, v in module_lookup.items()), body))

def spawn_missing_classes(self, context=None):
"""
Creates the appropriate python user relation classes from tables in the schema and places them
Expand Down
1 change: 0 additions & 1 deletion tests/test_blob2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import os
import datajoint as dj
from nose.tools import assert_equal, assert_true, assert_list_equal, assert_tuple_equal, assert_false

Expand Down