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

Improve _edge_definitions #25

Closed
muelldlr opened this issue Mar 8, 2023 · 0 comments · Fixed by #26
Closed

Improve _edge_definitions #25

muelldlr opened this issue Mar 8, 2023 · 0 comments · Fixed by #26

Comments

@muelldlr
Copy link
Collaborator

muelldlr commented Mar 8, 2023

Currently, the _edge_definitions specify the collections as strings. To be able to use introspection correctly, it should be possible to specify the class of the collection directly instead. I would make it as a backwards compatible change. Example:

class CollectionA(GenericOOSNode):
    _name = "CollectionA"
    _fields = {"value": Field(), "value2": Field(), **GenericOOSNode._fields}


class CollectionB(GenericOOSNode):
    _name = "CollectionB"
    _fields = {"value": Field(), **GenericOOSNode._fields}


class CollectionC(GenericOOSNode):
    _name = "CollectionC"
    _fields = {"value": Field(), **GenericOOSNode._fields}


class HasRelation(GenericEdge):
    _fields = GenericEdge._fields

class SampleGraphCreator(GraphCreatorBase):
    _name = "SampleGraphCreator"
    _description = "Sample Graph"

    _edge_definitions = [
        {
            "relation": "HasRelation",
            "from_collections": [CollectionA],
            "to_collections": [CollectionB],
        },
        {
            "relation": "HasAnotherRelation",
            "from_collections": [CollectionC],
            "to_collections": [CollectionC],
        },
    ]

    def init_graph(self):
        pass

Currently you often see the example with CollectionA._name. Accessing a protected variable in this way also leads to a warning in the IDEs. We should try to be PEP8 compatible if possible.

Furthermore, this change allows a good solution for #24, where I have to introspect _edge_definitions.

muelldlr pushed a commit that referenced this issue Mar 8, 2023
@muelldlr muelldlr linked a pull request Mar 8, 2023 that will close this issue
muelldlr pushed a commit that referenced this issue Mar 10, 2023
muelldlr pushed a commit that referenced this issue Mar 10, 2023
roxanneelbaff added a commit that referenced this issue Mar 10, 2023
merging pull request for issue #25 on behalf od @muelldlr
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 a pull request may close this issue.

1 participant