Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked dependencies and table definitions #72

Merged
merged 51 commits into from
Apr 3, 2017

Conversation

dimitri-yatsenko
Copy link
Member

  • Dependencies are now handled using matlab's new graph object
  • Added support for aliased foreign keys
  • New tables are now created as in datajoint-python using classes dj.Manual, dj.Lookup, dj.Imported, dj.Computed, and dj.Part.
  • Updated dj.new and dj.Relvar/describe to use the new format.
  • Backward compatibility is preserved

Copy link
Contributor

@eywalker eywalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the changes in its entirety and made a few change suggestions. Please review my suggestions and let's discuss further.

Also, let's remove .gitmodules as we don't use it.

s = sprintf(', %s',self.nonKeyFields{:});
fprintf('Dependent attributes: %s', s(2:end))
hdr = self.header;
try
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use try...catch instead of explicit check for presence of tableHeader attribute?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you don't mind addressing this question?

end
maxRows = 12;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like in Python, maxRows ought to be configurable via dj.set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@@ -81,7 +81,7 @@
attrs.isNumeric = ~cellfun(@(x) isempty(regexp(sprintf('%s',x), ...
'^((tiny|small|medium|big)?int|decimal|double|float)', 'once')), attrs.type);
attrs.isString = ~cellfun(@(x) isempty(regexp(sprintf('%s',x), ...
'^((var)?char|enum|date|year|time|timestamp)','once')), attrs.type);
'^((var)?char|enum|date|(var)?binary|year|time|timestamp)','once')), attrs.type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is (var)? match labeling repeated here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not repeated. The first (var)? belong to varchar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok I've mistaken it for the match labeling syntax.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not labeling but an optional character sequence in regular expressions. (var)?char is equivalent to varchar|char

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I know - I mistook it for the (?<groupname>) syntax.

@@ -32,6 +32,7 @@
% computed: tableName with '__'
allowedTiers = {'lookup' 'manual' 'imported' 'computed' 'job'}
tierPrefixes = {'#', '', '_', '__', '~'}
tierClasses = {'dj.Lookup' 'dj.Manual' 'dj.Imported' 'dj.Computed' 'dj.Jobs'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I much prefer that we place the tierPrefix information directly inside the corresponding class, rather than using the class as mere naming magic.

Copy link
Member Author

@dimitri-yatsenko dimitri-yatsenko Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be implemented once we completely transition to the new implementation. The old implementation did not have corresponding classes and it is still being used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand but we could go ahead and push the tier prefix information into the class while still supporting the older syntax - I don't like how the UserRelation classes are completely empty and placing tier prefix can be a useful information in the class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but I think we can hold off with that since it modifies existing functions. I am working on unit regression tests and changes like these will be easier to make.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I agree that such changes are better after unit tests are in place.

@@ -7,7 +7,7 @@
properties(SetAccess = private)
package % the package (directory starting with a +) that stores schema classes, must be on path
dbname % database (schema) name
prefix='' % optional table prefix, allowing multiple schemas per database
prefix='' % optional table prefix, allowing multiple schemas per database -- remove this feature if not used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about this feature - I have never seen it being used and it may be an unnecessary complexity.

Copy link
Member Author

@dimitri-yatsenko dimitri-yatsenko Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we need to remove it. Only Florian has used it when they had a very unreasonable constraint: they were now allowed to create more databases on their server. I am not even sure if it works since no one here has used it.

+dj/Table.m Outdated
end


function str = re(self)
% dj.Table/re - "reverse engineer" the table declaration.
% alias for self.re
warning 'dj.Table/re is deprecated: Use dj.Table/describe instead'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's include message as to when we plan on fully removing this deprecated feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason to remove it in the near future? I think we will let it linger around for a bit longer and then add the message once no one uses it anymore.

Copy link
Contributor

@eywalker eywalker Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it says deprecated, I think it only makes sense that we remove it at some point. Not sure how immediate it should be though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this, although the word deprecated already implies that the feature may no longer be supported in the future.

+dj/Table.m Outdated
@@ -493,8 +466,8 @@ function syncDef(self)
fprintf('File %s.m is not found\n', self.className);
else
if ~dj.set('suppressPrompt') ...
&& ~strcmpi('yes', dj.ask(sprintf('Update table declaration in %s?',path)))
disp 'No? Table declaration left untouched.'
&& ~strcmpi('yes', dj.ask(sprintf('Update table definition in %s?',path)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include explicit message stating that the table will be subclassed from the correct UserRelation - this will help point out the new syntax.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@eywalker eywalker merged commit 338deee into datajoint:development Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants