This repository was archived by the owner on Aug 8, 2026. It is now read-only.
Repository navigation
Fix bug in setting DVC remote for new project and track API latency better - #664
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses failures during new-project setup when using a default ck:// DVC remote, and improves production observability for backend latency and 5xx errors (Grafana + Prometheus buckets).
Changes:
- Register
ck://support early in-process and run DVC viapython -m calkit dvcto ensure the scheme is available in subprocesses. - Make project-creation flow more robust against DB uniqueness races and add a regression test for
ck://DVC config + CLI operations. - Improve API monitoring by extending latency histogram buckets and enhancing the FastAPI Grafana dashboard with a dedicated 500s log panel.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| config/grafana/provisioning/dashboards/fastapi.json | Reformats panels and adds a Loki-backed “Backend 500s” log panel; adjusts layout accordingly. |
| backend/uv.lock | Updates lockfile for calkit-python==0.41.24 and pulls in new dependency set (notably DVC extras). |
| backend/pyproject.toml | Bumps calkit-python dependency to 0.41.24. |
| backend/app/tests/test_dvc.py | Adds regression test ensuring ck:// scheme works for both config validation and DVC CLI. |
| backend/app/projects.py | Handles concurrent insert race when caching GitHub collaborator permissions (IntegrityError). |
| backend/app/main.py | Extends Prometheus latency histogram buckets for better tail visibility. |
| backend/app/dvc.py | Registers ck:// scheme at import time and introduces run_dvc_command wrapper using calkit dvc. |
| backend/app/api/routes/projects/core.py | Switches DVC subprocess calls to run_dvc_command and adds rollback/delete cleanup on setup failures. |
Suppressed comments (4)
backend/app/api/routes/projects/core.py:593
run_dvc_command(["config", ...])return code is ignored. If this fails, we’ll still commit/push and leave the repo in an unexpected state. Usingcheck=Truehere would make failures raise and be handled by the outertry/except.
logger.info("Enabling DVC autostage")
run_dvc_command(
["config", "core.autostage", "true"],
wdir=str(repo.working_dir),
)
backend/app/api/routes/projects/core.py:3274
dvc inithere is executed withoutcheck=True, so a failure will be ignored and the subsequentdvc addwill fail with a less-direct error. Consider checking init to fail fast when DVC can’t initialize in this repo.
if not os.path.isdir(os.path.join(repo.working_dir, ".dvc")):
logger.info("Calling dvc init since .dvc directory is missing")
run_dvc_command(["init"], wdir=str(repo.working_dir))
backend/app/api/routes/projects/core.py:3697
dvc inithere is executed withoutcheck=True, so a failure will be ignored and the subsequentdvc addwill fail with a less-direct error. Consider checking init to fail fast when DVC can’t initialize in this repo.
if not os.path.isdir(os.path.join(repo.working_dir, ".dvc")):
logger.info("Calling dvc init since .dvc directory is missing")
run_dvc_command(["init"], wdir=str(repo.working_dir))
backend/app/api/routes/projects/core.py:2225
dvc inithere is executed withoutcheck=True, so a failure will be ignored and the subsequentdvc addwill fail with a less-direct error. Making init checked gives a clearer failure mode and avoids proceeding when DVC isn’t initialized.
if not os.path.isdir(os.path.join(repo.working_dir, ".dvc")):
logger.info("Calling dvc init since .dvc directory is missing")
run_dvc_command(["init"], wdir=str(repo.working_dir))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+585
to
588
| logger.info("Running DVC init") | ||
| run_dvc_command( | ||
| ["init", "--force", "-q"], wdir=str(repo.working_dir) | ||
| ) |
| "https://raw.githubusercontent.com/calkit/devcontainer/" | ||
| "refs/heads/main/devcontainer.json" | ||
| ) | ||
| dc_resp = requests.get(dc_url) |
Comment on lines
+155
to
+159
| try: | ||
| session.commit() | ||
| except IntegrityError: | ||
| logger.info("Access record was written concurrently; ignoring") | ||
| session.rollback() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.