Skip to content
This repository was archived by the owner on Aug 8, 2026. It is now read-only.

Fix bug in setting DVC remote for new project and track API latency better - #664

Merged
petebachant merged 3 commits into
mainfrom
new-project-500
Aug 5, 2026
Merged

petebachant merged 3 commits into
mainfrom
new-project-500

Conversation

@petebachant

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 via python -m calkit dvc to 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. Using check=True here would make failures raise and be handled by the outer try/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 init here is executed without check=True, so a failure will be ignored and the subsequent dvc add will 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 init here is executed without check=True, so a failure will be ignored and the subsequent dvc add will 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 init here is executed without check=True, so a failure will be ignored and the subsequent dvc add will 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)
)
Comment thread backend/app/api/routes/projects/core.py Outdated
"https://raw.githubusercontent.com/calkit/devcontainer/"
"refs/heads/main/devcontainer.json"
)
dc_resp = requests.get(dc_url)
Comment thread backend/app/api/routes/projects/core.py Outdated
Comment thread backend/app/projects.py
Comment on lines +155 to +159
try:
session.commit()
except IntegrityError:
logger.info("Access record was written concurrently; ignoring")
session.rollback()
@petebachant
petebachant merged commit 294d6d7 into main Aug 5, 2026
4 checks passed
@petebachant
petebachant deleted the new-project-500 branch August 5, 2026 20:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants