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(generate): restructure file generation of conf and spec files #1299

Closed
wants to merge 26 commits into from

Conversation

hetangmodi-crest
Copy link
Contributor

@hetangmodi-crest hetangmodi-crest commented Jul 24, 2024

Issue number:

Summary

Changes

Please provide a summary of what's being changed

User experience

Please describe what the user experience looks like before and after this change

Checklist

If your change doesn't seem to apply, please leave them unchecked.

@hetangmodi-crest hetangmodi-crest self-assigned this Jul 24, 2024
@hetangmodi-crest hetangmodi-crest changed the title Feat/restructure file generation feat(generate): restructure file generation of conf and spec files Jul 24, 2024
docs/generated_files.md Show resolved Hide resolved
super().__init__(global_config, input_dir, output_dir, **kwargs)
self.conf_file = "inputs.conf"

def _set_attributes(self, **kwargs: Any) -> None:
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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):
Copy link
Contributor

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.

Copy link
Contributor Author

@hetangmodi-crest hetangmodi-crest Jul 26, 2024

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?

@hetangmodi-crest hetangmodi-crest force-pushed the feat/restructure-file-generation branch from a43dde6 to c4e8870 Compare July 31, 2024 10:36
@hetangmodi-crest hetangmodi-crest force-pushed the feat/restructure-file-generation branch from c4e8870 to cd48a8c Compare July 31, 2024 10:57
@hetangmodi-crest
Copy link
Contributor Author

Closing the PR as this PR has been broken down into PRs - #1311, #1312, #1328 and #1329. Hence, closing this PR.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2024
@hetangmodi-crest hetangmodi-crest deleted the feat/restructure-file-generation branch September 19, 2024 09:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants