-
Notifications
You must be signed in to change notification settings - Fork 2
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: Central Hierarchy + Environment design populated by Actions #15
Conversation
DISCLAIMER: Implementations of Action are here just for illustration, they have to be refine. This commit just demonstrates an idea for the overall architecture. An instance of Hierarchy stores all information about configurations files and templated files to write for the new project. Then each tool is modeled by Action instances, they populate a hierarchy instance and define pre and post methods to run before and after the creation of the project files. E.g. Git Action pre method runs git init, while post method runs git add --all and git commit. Definitions of configurations and templates can be done with environment variables, like {NAME}. All those variables are stored in an Environment instance, it is initialized with environment variables system and can be modified by any Action using pre or post methods. Then values are used when needed and asked to user if missing. When an Action is created, it can also register itself a hook, e.g. Git Action register a VCSIgnore hook that defines how a pattern is ignored by git. Then any Action can used those hooks, e.g. Venv Action use VCSIgnore to make VCS system aware of ignoring .env folder.
Use click for requestion missing environment variables and choosing between multiple values.
Environment variables should be confirmed even if already registered, except if explicitly push as `confirmed`. Configuration files are also purged of `None`/ empty list values before being written. Then registered but unconfirmed values are used as default values for `click.prompt`.
c402f32
to
dfce84c
Compare
* fix: __repr__ and __eq__ for MultipleValues * test: remove dummy test * fix: first proposal for TemplateDict internal
About last push
Maybe we should ditch template_dict["first", "second", "third"] = something in favor of template_dict["first"] = {"second": {"third": something}} and check for overrides in |
I don't really like all those
I don't think so, this syntax seems more clear and simple than the other. |
Me neither, but I'm unsure about how to get rid of them. Maybe an iterative approach will suit this case better than the current, recursive one.
It is, but I see two issues with it:
|
generated trough new utility functions
- ditch out most of the recursion - ditch out static methods - replace set_items with __ior__ syntax - add Transform namedtuple class - update tests accordingly - update docutils module accordingly Co-authored-by: fblanchetNaN <florian.blanchet.supop@gmail.com>
New design for TemplateDict
feat: add README.md in setuptools Action
Co-authored-by: Le minaw <leminaw@gmail.com>
fix: move TemplateDict related cls to new module
ea4c528
to
d335b18
Compare
5af799e
to
0a80f69
Compare
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.
The last few commits are great, I've only a few nitpicking comments huhu. Let's look forward to merge this branch!
fix: miscellaneous naming
df70ee9
to
b33c1b9
Compare
Codecov Report
@@ Coverage Diff @@
## main #15 +/- ##
=========================================
+ Coverage 0 66.28% +66.28%
=========================================
Files 0 13 +13
Lines 0 519 +519
=========================================
+ Hits 0 344 +344
- Misses 0 175 +175
Continue to review full report at Codecov.
|
b33c1b9
to
96b7f65
Compare
96b7f65
to
5d2aedc
Compare
f931fa0
to
6bb4fcf
Compare
6bb4fcf
to
47fc705
Compare
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.
Plus qu'à nettoyer un peu les commits :)
b83e1cf
to
86fb76f
Compare
[#9 automatically closed after rebase + push --force, cannot be reopen]
The design is based on two central classes:
Hierarchy
with two attributes_configurations
and_templates
incipyt/incipyt/system.py
Lines 127 to 143 in dc3fdde
incipyt/_internal/dumpers
-- path-like classes with a specific method to write them, e.g. for Tomlincipyt/incipyt/_internal/dumpers.py
Lines 71 to 74 in dc3fdde
_templates
, values are just Jinja template._configurations
is dedicated to all configuration files based on key-value syntax (toml, cfg, ini, yaml, json, etc), values of this dictionary are then nested dictionary describing this configuration file.Envrionment
is basically a wrapper around a dictionary initiated with environment variables,incipyt/incipyt/system.py
Lines 13 to 65 in dc3fdde
{NAME}
or{AUTHOR}
that should be asked to the user. To do so,incipyt/incipyt/system.py
Lines 67 to 74 in dc3fdde
Hierarchy._configuration
incipyt/incipyt/system.py
Lines 97 to 108 in dc3fdde
callable
instead ofstr
, if so thosecallable
are call and the value substituted. Typically, it can beutils.Requires("{NAME}")
withincipyt/incipyt/_internal/utils.py
Lines 12 to 28 in dc3fdde
Environment
for{NAME}
:environment.pull(key)
.There are similar substitution mechanisms for
_template
and also for usingsubprocess.run
incipyt/incipyt/system.py
Lines 110 to 124 in dc3fdde
The main workflow is then to initialize a
Hierarchy
and let tool specific classes populate_configurations
and_template
incipyt/incipyt/system.py
Lines 242 to 245 in dc3fdde
An instance of Hierarchy stores all information about configurations files and templated files to write for the new project.
Then each tool is modeled by Action instances, they populate a hierarchy instance and define pre and post methods to run before and after the creation of the project files
incipyt/incipyt/system.py
Lines 250 to 259 in dc3fdde
Definitions of configurations and templates can be done with environment variables, like {NAME}. All those variables are stored in an Environment instance, it is initialized with environment variables system and can be modified by any Action using pre or post methods. Then values are used when needed and asked to user if missing.
When an Action is created, it can also register itself a hook, e.g. Git Action register a VCSIgnore hook that defines how a pattern is ignored by git. Then any Action can used those hooks, e.g. Venv Action use VCSIgnore to make VCS system aware of ignoring .env folder
incipyt/incipyt/actions/git.py
Lines 6 to 24 in dc3fdde