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

Poetry project #2

Merged
merged 18 commits into from
Jan 21, 2025
Merged

Poetry project #2

merged 18 commits into from
Jan 21, 2025

Conversation

mki-c2c
Copy link
Contributor

@mki-c2c mki-c2c commented Jan 14, 2025

setup quality tools and dependencies with poetry

Base automatically changed from docker_compose_root to docker January 20, 2025 09:06
@mki-c2c mki-c2c changed the base branch from docker to main January 21, 2025 07:44
@mki-c2c mki-c2c changed the base branch from main to docker January 21, 2025 07:45
@mki-c2c mki-c2c requested a review from arnaud-morvan January 21, 2025 07:59
Base automatically changed from docker to main January 21, 2025 10:54
Copy link
Contributor

@arnaud-morvan arnaud-morvan 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.
I made many comments, some may be addressed later or not at all.

backend/maelstro/main.py Outdated Show resolved Hide resolved
backend/maelstro/main.py Outdated Show resolved Hide resolved
backend/maelstro/main.py Show resolved Hide resolved

cd "$(dirname "$0")"/..

poetry run black --check . && \
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 consider using pre-commit: https://pre-commit.com/

IMHO those files don't need to be inside the Python package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this case, pre-commit would be too cumbersome

And for the scripts I really wonder. They are placed inside the package since they use the package dependencies. This is a hard choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand you need it in Docker images, but having them in Python package seems weird to me. BTW not sure it is really important.

backend/Dockerfile Outdated Show resolved Hide resolved
backend/Dockerfile Outdated Show resolved Hide resolved
from fastapi_cli.utils.cli import get_uvicorn_log_config


def dev():
Copy link
Contributor

@arnaud-morvan arnaud-morvan Jan 21, 2025

Choose a reason for hiding this comment

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

Not sure we really need those different entrypoints.

I would consider using environment variables or overwriting command in docker-compose.override.yaml

Note that such env vars might already exists in uvicorn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's comfortable for now, we can discuss this later

@mki-c2c mki-c2c changed the base branch from main to docker January 21, 2025 11:19
@mki-c2c mki-c2c changed the base branch from docker to main January 21, 2025 11:49
from fastapi import FastAPI, Request, Response, Header


app = FastAPI(root_path="/maelstrob")
Copy link
Member

Choose a reason for hiding this comment

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

can we consider renaming the path to maelstro-backend ?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 seems clearer

"""
Check if the user is authorized for the maestro sync platform via the MAELSTRO role
"""
return {"is_authorized": "ROLE_MAELSTRO" in sec_roles.split(";")}
Copy link
Member

Choose a reason for hiding this comment

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

IMO, this is not the application's role to check this, rather the gateway or SP's
cc @f-necas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

justement sec_roles est produit par la gateway, qui a vérifié que l'utilisateur est bien authentifié. Je suis confus alors.

bien sur, il faudrait mettre la constante "ROLE_MAELSTRO" dans un fichier de conf

Copy link
Collaborator

@f-necas f-necas Jan 21, 2025

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Oui, si j'ai bien compris les requêtes n'arrivent ici que si l'utilisateur à le role, sinon c'est le SP ou la gateway qui renvoie une erreur.

Je ne comprends pas bien non plus l'utilité de cet entrypoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

je l'enlève

@mki-c2c mki-c2c merged commit 0e152a8 into main Jan 21, 2025
1 check passed
@f-necas f-necas deleted the poetry_project branch January 21, 2025 15:28
build: ./backend
build:
context: ./backend
target: server
volumes:
- ./backend:/app
healthcheck:
Copy link
Member

Choose a reason for hiding this comment

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

Usually you include the healthcheck into the Dockerfile not the healthcheck section of the docker composition.

Adding health check to the Dockerfile, will make the health-check part of the image, so that anyone pulling the image from the registry will get the health check by default.

https://docs.docker.com/reference/dockerfile/#healthcheck


CMD ["serve_prod"]

FROM server as check
Copy link
Member

@edevosc2c edevosc2c Jan 22, 2025

Choose a reason for hiding this comment

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

In my opinion, having multiple docker images from the same Dockerfile using targets makes it very confusing. And you can't just do a simple "docker build -t XX ."

Why not having two Dockerfile but one major one that build the maelstro server docker image. And then another Dockerfile for "check" that reference the docker image built for maelstro server?

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.

6 participants