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

Add classes for Inheritance #134

Merged
merged 11 commits into from
Nov 23, 2021
Merged

Add classes for Inheritance #134

merged 11 commits into from
Nov 23, 2021

Conversation

PythonFZ
Copy link
Member

@PythonFZ PythonFZ commented Nov 16, 2021

fix #133

TODOs

  • Consider renaming Base and Child
  • consider changing Child to a dataclass containing all possible dvc/zn options and also include all of them in the Base
  • try making Base.methods some sort of abstractmethod?
  • documentation
  • docstrings
    - [ ] tests (no idea how to test them yet!) moved to Add Tests for #134 #141
  • what about multiple methods

Maybe rename .method to something that can not be mixed up with class methods?

Example

class Node:
    my_method_1 = zn.method()
    my_method_2 = zn.method()

node = Node()
node.my_method_1 = HelloWorld(name="John")
node.my_method_1 = HelloWorld(name="Jane")

This would - remove the inheritance for the parent, naming conventions, abstract method of methods, multiple methods and also one does not keep a dictionary up-to-date because it is not required anymore. It currently requires setting e.g. the outs/deps/... from the child method manually.

using importlib as follows

# SAVE
methods = {
    "module": cls.__class__.__module__,
    "name": cls.__class__.__name__,
    "kwargs": {}

}

for key in inspect.signature(cls.__class__.__init__).parameters:
    if key == "self":
        continue
    if key in ["args", "kwargs"]:
        log.error(f"Can not convert {key}!")
        continue
# LOAD
module = importlib.import_module(methods['module'])
cls = getattr(module, methods['name'])

instance = cls(**methods['kwargs'])

@SamTov
Copy link
Member

SamTov commented Nov 22, 2021

I think the idea is really nice. I am bit confused or I guess unsure of the mix with both named nodes and the idea of attaching methods. Can you run through what the over all idea is?

@PythonFZ PythonFZ marked this pull request as ready for review November 23, 2021 15:15
@PythonFZ PythonFZ mentioned this pull request Nov 23, 2021
@PythonFZ PythonFZ requested a review from SamTov November 23, 2021 15:17
Copy link
Member

@SamTov SamTov left a comment

Choose a reason for hiding this comment

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

great changes to the project.

@SamTov SamTov merged commit ecd8b06 into main Nov 23, 2021
@PythonFZ PythonFZ deleted the PythonFZ_add_interheritance branch November 29, 2021 11:48
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.

Parent class for using Subclasses
2 participants