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

Remove app creation at module level + refactoring #63

Merged
merged 1 commit into from
Feb 6, 2025
Merged

Conversation

mpangrazzi
Copy link
Contributor

This may seems a bit convoluted, but actually contains minor refactoring and improvements:

app instance

I've removed the app creation at module level in app.py. We were instantiating app each time that module is imported and this is not optimal. Now we're using only the create_app helper.

This will allow users to programmatically create their app instance, adding required middlewares when needed (e.g. for CORS, authentication or authorization). It's also used in hayhooks run CLI command. This will be better documented on another PR.

Test improvements

  • Removed the various TestClient instances around test files and used a single one as a fixture in conftest.py.
  • Override settings for tests, creating pipelines dir in tests dir.
  • Automatic cleanup of pipelines dir after each test module run.

Folder -> Dir

There were many references to folder and dir concepts. I've chosen dir and removed folder references (but not yet in README.md and deployment_guidelines.md, another PR will take care of this).

Copy link
Member

@vblagoje vblagoje left a comment

Choose a reason for hiding this comment

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

Looks good, only one adding types comment - not sure if applicable here?

def deploy_files(server_conf, name, folder):
"""Deploy all pipeline files from a folder to the Hayhooks server."""
@click.argument('pipeline_dir', type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path))
def deploy_files(server_conf, name, pipeline_dir):
Copy link
Member

Choose a reason for hiding this comment

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

Shall we add types here?

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 can, but to tell you the truth I was planning to add fastapi[standard] as a dep and then rewrite the CLI commands using Typer, which is cleaner and has a stronger types support. I've already written it actually, but wanted to tackle those other refactoring first 😉

@vblagoje vblagoje self-requested a review February 6, 2025 16:02
@mpangrazzi mpangrazzi merged commit 77c70ea into main Feb 6, 2025
4 checks passed
@mpangrazzi mpangrazzi deleted the app_instance branch February 6, 2025 16:21
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.

3 participants