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

Add project creation API endpoint #139

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

AdrianoKF
Copy link
Collaborator

@AdrianoKF AdrianoKF commented Oct 31, 2024

This PR adds the data model for the Project entity, along with a creation API endpoint POST /projects:

image

An Alembic migration that includes the project table has been created.

Behavior of the POST /projects creation endpoint:

  • Kubernetes resources (i.e., namespace, Kueue cluster&local queue) are attempted to be looked up from the cluster
  • If any referenced k8s resource does not exist, it is created with default values

Note

Testing: the db() fixture in tests/integration/conftest.py automatically creates a temporary SQLite database and applies all database migrations.

If you want to manually inspect the database contents after a test session, you can put a breakpoint() after the yield statement and get the database path from f.name.

Open Questions

  • Need to add finalizers to k8s resources (remove TODO comment)
  • Integration tests are failing due to insufficient mocking

Integration tests are missing pending a suitable mocking strategy.
@AdrianoKF AdrianoKF added enhancement New feature or request backend Related to the backend / server component. labels Oct 31, 2024
@AdrianoKF AdrianoKF self-assigned this Oct 31, 2024
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 87.84530% with 22 lines in your changes missing coverage. Please review.

Project coverage is 58.91%. Comparing base (7dcdb6a) to head (76229ad).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
backend/src/jobq_server/services/kueue.py 75.00% 11 Missing ⚠️
backend/src/jobq_server/routers/projects.py 84.37% 5 Missing ⚠️
...er/alembic/versions/2837c7c54f35_initial_schema.py 80.00% 3 Missing ⚠️
backend/src/jobq_server/services/k8s.py 81.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
+ Coverage   57.34%   58.91%   +1.57%     
==========================================
  Files          66       69       +3     
  Lines        3247     3420     +173     
==========================================
+ Hits         1862     2015     +153     
- Misses       1385     1405      +20     
Flag Coverage Δ
backend 86.88% <87.84%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 66 to 67
# Create local queue if it doesn't exist
local_queue = kueue.get_local_queue(project.local_queue, project.namespace)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could also be an ensure pattern like the namespace bit above, or am I missing something?

i.e. local_queue = kueue.ensure_local_queue(...)


class LocalQueueResourceUsage(BaseModel):
name: str
total: Any
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is that a JSON struct, or something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to the backend / server component. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants