Giter Club home page Giter Club logo

Comments (18)

aecker avatar aecker commented on September 28, 2024

I agree to formalizing the master/part relationship. However, I suggest simplifying the complex syntax part of schema.Class. Instead, let's use only part and define the first reference (i.e. -> schema.Class) as the master.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

I have considered that option but it seems like another implicit rule that must be explained in the documentation. I am not sure if there are cases when users might not want to have the first dependency to be on the master table. I have not yet thought of such an example but I am thinking of its potential uses.

from datajoint-matlab.

fabiansinz avatar fabiansinz commented on September 28, 2024

I agree with Dimitri on that. Such kind of implicit rules can potentially lead to obscure behaviour. I don't think that part of ... is really a complex syntax and it makes it very clear what is happening.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

We can throw a warning if the first dependency is not on the master table.

from datajoint-matlab.

aecker avatar aecker commented on September 28, 2024

It just feels unnecessarily redundant. In principle the entire first line of the definition is unnecessary; we could just subclass from dj.Imported, dj.Part etc. as in Python. So when we're changing the syntax anyway, I'd rather reduce redundancy that increase it. Ideally we use every name exactly once.

What would be a use case where the first reference is not the master? The order of references does not matter anyway, does it?

What kind of obscure behavior do you expect? From what I can tell the master/part relationship does not produce any "behavior". The only potential behavior I can see is preventing it from implementing makeTuples(), but the only way I can see we can accomplish that in Matlab is by defining the table their by subclassing dj.Part as in Python and not deriving dj.Part from dj.AutoPopulate.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

Yes, we could subclass from new classes dj.Manual, and dj.Lookup, dj.Imported, dj.Computed, etc. However, this would introduce backward incompatibility.

Master/part relationship has consequences for deletions. Our current plan is to delete the master if any of the parts is deleted. This prevents deleting any parts independently.

Another implication is for naming conventions. On the Python side, the convention is schema.master_name__part_name with double underscore separating the two names.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

The only problem that remains unresolved is issue #40. This is not a problem in python, because tables are created at the time of importing the module. In MATLAB, tables are created at the time of first use. This causes an implicit commit during transactions, which is a particular problem for part relations because they might not be first used until they are called from inside their master's makeTuples call.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

One solution for #40 is to make the master aware of all its parts and make it instantiate all the parts before entering the makeTuples transaction. What's the best syntax or mechanism for that?

from datajoint-matlab.

eywalker avatar eywalker commented on September 28, 2024

We might have to crawl the search path to discover all the classes that inherits from dj

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

Crawling the search path could take seconds every time.

One approach is to declare parts as properties of master.

classdef Master < dj.Relvar
    properties(Constant)
        parts = [schema.Part1, schema.Part2]
    end
end

One problem is that matlab has a hard time clearing properties of classes. Another problem is that now master/part relationship is established in two places.

from datajoint-matlab.

eywalker avatar eywalker commented on September 28, 2024

I would be strongly opposed to manipulating (constant) properties in Matlab - it' gets messy very quickly. Maybe we can maintain the list of parts in a separate file that gets read in? This sounds terrible because it'll be another separate file, but it will be cleaner update.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

Parts could also be listed in the table declaration.

from datajoint-matlab.

eywalker avatar eywalker commented on September 28, 2024

But if you modify it later, wouldn't that be a mess?

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

We could list them in a string:

classdef Master < dj.Relvar
    properties(Constant)
        parts = 'Part1, Part2'
    end
end

from datajoint-matlab.

eywalker avatar eywalker commented on September 28, 2024

Actually I take that back - if we put that as part of the comment at the top, it's no different from my separate file with list solution.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

@eywalker and I just spoke and came up with the following:

  1. If a table declaration is attempted within a transaction, an error will be raised.
  2. Master and part must be in the same schema (that's also true in Python)
  3. Parts will be declared with part of schema.Master in the first line of the declaration.
  4. When populate gets called, it will examine all the .m files in the package, parse the declarations, and find all classes that declare themselves as part of the calling class. It will then instantiate all the part classes and trigger their declarations.

from datajoint-matlab.

dimitri-yatsenko avatar dimitri-yatsenko commented on September 28, 2024

Fixed in #72 by introducing a the dj.Part class.

from datajoint-matlab.

eywalker avatar eywalker commented on September 28, 2024

Master and pard table concepts are now formally introduced into DataJoint MATLAB beginning in v3.0.0 (PR #83). @dimitri-yatsenko Should we just close this issue now?

from datajoint-matlab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.