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

feat: Add config loader and store method #23

Merged
merged 8 commits into from
May 12, 2023
Merged

feat: Add config loader and store method #23

merged 8 commits into from
May 12, 2023

Conversation

realamirhe
Copy link
Member

Make function call is still needed after the configuration file is saved and loaded. but it seems modular to me. open for suggestions

Related to #17

Copy link
Collaborator

@atenagm1375 atenagm1375 left a comment

Choose a reason for hiding this comment

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

  • Load can call the make method at the end.
  • support for json file can be added as well.

@atenagm1375 atenagm1375 linked an issue May 5, 2023 that may be closed by this pull request
@realamirhe
Copy link
Member Author

The json support can easily be added, but for calling make at the end I'm not sure it's the best way to handle it, I was thinking about the more generic loader, which load and make each module with more ease, here the user must copy and paste some code blocks for simple configuration restoration.

But I'm okay to call make at the end of each load section :)

@saeedark
Copy link
Collaborator

saeedark commented May 6, 2023

@atenagm1375 Load should not call the make method. make method constructs the dictionary a Module uses. However, it's reasonable to have a function that makes a config instance automatically. Since we have multiple classes for config I'm lost on how an automake for config should work. (the body of the make method for each class is different...)

@atenagm1375
Copy link
Collaborator

@atenagm1375 Load should not call the make method. make method constructs the dictionary a Module uses. However, it's reasonable to have a function that makes a config instance automatically. Since we have multiple classes for config I'm lost on how an automake for config should work. (the body of the make method for each class is different...)

I still don't get the point. Upon calling load, the user should be able to retrieve either the config instance or the dictionary itself. Right now, nothing is returned by load and the user should instantiate a Config, call load on it, and then call a make. All this is redundant and inconsistent. I know that make is not the same for all config types, but load is a method inherited in all of them and can be overridden. Tell me which part is exactly impractical, so that we can come up with a solution.

@saeedark
Copy link
Collaborator

saeedark commented May 7, 2023

First sorry for the unrelated commit.

load_from_yaml now returns a dictionary of instances. @atenagm1375 @realamirhe

@@ -52,6 +52,8 @@ def __init__(
self.network = net
net.input_layers.append(self)

sensory_tag = "Sensory" if sensory_tag is None else "Sensory," + sensory_tag
Copy link
Collaborator

Choose a reason for hiding this comment

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

make sure that no errors or issues will be encountered in this format. using underline rather than comma is safer in my opinion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nein. (add_tag process this tag(made of comma-separated tags))

@@ -52,6 +52,8 @@ def __init__(
self.network = net
net.input_layers.append(self)

sensory_tag = "Sensory" if sensory_tag is None else "Sensory," + sensory_tag
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nein. (add_tag process this tag(made of comma-separated tags))

@saeedark
Copy link
Collaborator

Why haven't we merged this already?

@atenagm1375
Copy link
Collaborator

Why haven't we merged this already?

waitning for @realamirhe approval

@realamirhe
Copy link
Member Author

JSON structure must also be added, I'm going to add it right now

@saeedark
Copy link
Collaborator

saeedark commented May 11, 2023

I think The easiest way is to find a custom jsonEncoder or write one that supports callables.

NOTE: there is an issue with restoration of classes
@realamirhe
Copy link
Member Author

realamirhe commented May 11, 2023

I think The easiest way is to find a custom jsonEncoder or write one that supports callable.

Do you have any idea how we could have the encoding for all JSON structures inside the default_loader?
@saeedark

Copy link
Collaborator

@atenagm1375 atenagm1375 left a comment

Choose a reason for hiding this comment

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

LGTM

@realamirhe realamirhe self-assigned this May 11, 2023
@saeedark
Copy link
Collaborator

I think The easiest way is to find a custom jsonEncoder or write one that supports callable.

Do you have any idea how we could have the encoding for all JSON structures inside the default_loader? @saeedark

honestly no.

@realamirhe
Copy link
Member Author

@atenagm1375 if there is a task with higher priority, it might be better to merge this PR and wait for a more mature json load-save with jsonEncoder on the mapping-proxy structures.
If not I'm going to test some more implementations of default-loader till next session

@atenagm1375 atenagm1375 merged commit a618144 into main May 12, 2023
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.

enable read and write of configs to/from files
3 participants