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

Generating new application with flask-server template fails #558

Open
afonsobspinto opened this issue Sep 7, 2022 · 6 comments
Open

Generating new application with flask-server template fails #558

afonsobspinto opened this issue Sep 7, 2022 · 6 comments
Labels
bug Something isn't working scope:code-generation

Comments

@afonsobspinto
Copy link
Member

Running:

harness-application clockdate -t flask-server

with latest develop

returns:

WARNING:root:Overwriting file applications/clockdate/api/config.json with /home/afonso/Projects/MetaCell/cloud-harness/tools/cloudharness_utilities/application-templates/base/api/config.json
INFO:root:Merged/overridden file content of applications/clockdate/api/openapi.yaml with /home/afonso/Projects/MetaCell/cloud-harness/tools/cloudharness_utilities/application-templates/base/api/openapi.yaml
WARNING:root:Overwriting file applications/clockdate/test/api/test_st.py with /home/afonso/Projects/MetaCell/cloud-harness/tools/cloudharness_utilities/application-templates/base/test/api/test_st.py
WARNING:root:Overwriting file applications/clockdate/test/e2e/landing.spec.ts with /home/afonso/Projects/MetaCell/cloud-harness/tools/cloudharness_utilities/application-templates/base/test/e2e/landing.spec.ts
INFO:root:Merged/overridden file content of applications/clockdate/deploy/values.yaml with /home/afonso/Projects/MetaCell/cloud-harness/tools/cloudharness_utilities/application-templates/base/deploy/values.yaml
Traceback (most recent call last):
  File "/home/afonso/.pyenv/versions/ch/bin/harness-application", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/afonso/Projects/MetaCell/cloud-harness/tools/harness-application", line 73, in <module>
    generate_server(app_path)
TypeError: generate_server() missing 1 required positional argument: 'overrides_folder'

Expected:

  • Generate the application stubs
@afonsobspinto afonsobspinto added the bug Something isn't working label Sep 7, 2022
@afonsobspinto
Copy link
Member Author

afonsobspinto commented Sep 7, 2022

Some relevant notes:
The problem seems to happen here: https://github.com/MetaCell/cloud-harness/blob/develop/tools/harness-application#L73
And 'overrides_folder' was added on #515

It's also unclear to me if we are suppose to support both 'server' and 'flask-server' templates.
From the harness-application help, I would say we are not:
image

But the truth is that when I run harness-application clockdate -t server the app is built

@aranega
Copy link
Member

aranega commented Sep 7, 2022

Regarding the generation without failure using server, there is a special case for it here: https://github.com/MetaCell/cloud-harness/blob/develop/tools/harness-application#L62-L66

# ...
        if template_name == 'server':
            with tempfile.TemporaryDirectory() as tmp_dirname:
                copymergedir(os.path.join(HERE, APPLICATION_TEMPLATE_PATH, template_name), tmp_dirname)
                merge_configuration_directories(app_path, tmp_dirname)
                generate_server(app_path, tmp_dirname)
#...

@filippomc
Copy link
Collaborator

I think we should improve the way templates are used. The double template idea seems confusing to me in general. What are the combinations which are allowed and what not?
I would go for a simpler proposal where only one template can be used by the user, leaving the possibility for the developer to compose the application with multiple templates that are implicitly included. cc @zsinnema

@zsinnema
Copy link
Contributor

zsinnema commented Sep 7, 2022

may be cookiecutter can be of any help https://github.com/cookiecutter/cookiecutter

imo we should not combine templates and go for application types, e.g. Django microservice, Flask microservice, React micorservice etc

@aranega
Copy link
Member

aranega commented Sep 7, 2022

Feature models are really good to capture configuration options: what are the "features" that are required, their mandatory dependencies, the optional ones as well as the forbidden ones. You can validate them usually to check if there is some "dead" features, and at the end, if you give some features you want for your product, you can derive the mantory other features you need to take, the optional ones you could includes and rejects the features you cannot take (or inform you that you have features that cannot work together).
I never manipulated them on a tooling point of view, perhaps it's overkill right now...

@filippomc
Copy link
Collaborator

filippomc commented Sep 12, 2022

I'm afraid that the complexity start exploding really soon as we are in the O(n!) and we need to control the allowed ones. It's a very powerful strategy but I don't think the trade-off will be in our favour. For our sanity we should propose to the user a set of well defined possibilities with the choice of only one, leaving the possibility to compose templates to the developer -- this is how base and server templates were conceived, but the actual implementation (the if template_name == 'server') is too ad hoc to support more templates.
I'm also open to the feature based alternative if there's a solution out there we can use.

I like @zsinnema idea to base the templating on an established library/tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope:code-generation
Projects
None yet
Development

No branches or pull requests

4 participants