-
Notifications
You must be signed in to change notification settings - Fork 24
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(generate): restructure file generation of conf and spec files #1299
Conversation
super().__init__(global_config, input_dir, output_dir, **kwargs) | ||
self.conf_file = "inputs.conf" | ||
|
||
def _set_attributes(self, **kwargs: Any) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there is a need for that _set_attributes
method, when we still define __init__
for the subclasses.
Or maybe we should at least get rid of __init__
? Because this call to the superclass __init__
that needs to be added every time, looks weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I am not sure about using **kwargs
. Maybe we should at least leave **kwargs
in the base class but use real parameters in the overridden methods in subclasses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we could merge _set_attributes
and __init__
, I kept them different as to define what needs to be initialized and what attributes need to be set for self
for each individual classes. Should we merge them in __init__
?
Currently, **kwargs
is required by AppConf class to generate the details required for app.conf
which comes from build.py
(to avoid redoing of things), and perhaps in future for XML or Python or other file generation, we might require it. What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could for example at least leave def _set_attributes(self, **kwargs):
but change the method signature in subclasses to for example: def _set_attributes(self):
(when no parameters are needed), or def _set_attributes(self, some_param):
- type checking should accept that, I think and we'll get better error messages when some parameter is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the parent class is invoking the _set_attributes
, it will pass **kwargs
to whichever child class requires it. Moreover, I tried updating the method declaration to def _set_attributes(self)
where **kwargs
aren't required, and it raised a TypeError.
from ..file_generator import FileGenerator | ||
|
||
|
||
class ConfGenerator(FileGenerator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need this class between the base class and the actual subclasses? It only introduces generate_conf
and generate_conf_spec
methods and calls them. But I see not every conf file needs the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, from code, this class is redundant. However, my thought process in the design were to create a hierarchy of classes with justifiable bifurcation so that it is easier to maintain the procedures of file that are being generated and the order they should be generated in. Should we remove these bifurcation layers then?
a43dde6
to
c4e8870
Compare
c4e8870
to
cd48a8c
Compare
dbaaade
to
4db6be8
Compare
Issue number:
Summary
Changes
User experience
Checklist
If your change doesn't seem to apply, please leave them unchecked.