Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
tags: local/test-image:latest

- name: Run image help
run: docker run --rm --entrypoint "${{ github.event.repository.name }}" local/test-image:latest --help
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set image name
run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"

- name: Set short SHA
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV"

- name: Build and push image
uses: docker/build-push-action@v6
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ pyrightconfig.json
node_modules/

history.jsonl
uploader/clients/gen/
3 changes: 2 additions & 1 deletion .template.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Autogenerated - DO NOT EDIT
# Parameters of the project as generated from template
_commit: 00cbce2
_commit: f510818
_src_path: gh:kraysent/python-template
package_name: uploader
project_name: uploader
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM python:3.12-slim AS builder
FROM python:3.13-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
WORKDIR /app
COPY pyproject.toml uv.lock ./
COPY pyproject.toml uv.lock README.md ./
COPY uploader ./uploader
RUN uv sync --frozen --no-dev

FROM python:3.12-slim AS runtime
FROM python:3.13-slim AS runtime
WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH"
Expand Down
3 changes: 0 additions & 3 deletions app/crossmatch/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions app/crossmatch/layered/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions app/gen/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions app/sources/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions app/structured/designations/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions app/structured/icrs/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions app/structured/nature/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions app/structured/redshift/__init__.py

This file was deleted.

5 changes: 3 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ upgrade:
uv sync --all-extras --upgrade

gen:
mkdir -p uploader/clients/gen
uv run openapi-python-client generate \
--output-path app/gen/client \
--output-path uploader/clients/gen/client \
--overwrite \
--meta uv \
--config openapigen.yaml \
Expand All @@ -102,7 +103,7 @@ gen:
.PHONY: serve frontend dev check-frontend fix-frontend install-frontend install-dev-frontend

serve:
uv run uvicorn server.main:app --reload --port 8000
uv run uvicorn uploader.cli:app --reload --port 8000

frontend:
cd frontend && yarn dev
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ dependencies = [
"numpy>=2.3.4",
"pyvo>=1.8",
"psycopg[binary]>=3.2.0",
"click~=8.3.1",
]

[project.scripts]
"uploader" = "uploader.cli:cli"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = [
"ruff~=0.15.0",
Expand Down Expand Up @@ -120,7 +128,7 @@ reportImplicitAbstractClass = "error"

exclude = [
"frontend/**",
"app/gen/**",
"uploader/clients/gen/**",
".venv/**"
]

Expand Down
Empty file removed server/forms/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions tests/test_crossmatch_resolver.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from app.crossmatch.models import (
from uploader.app.crossmatch.models import (
CrossmatchResult,
CrossmatchStatus,
Neighbor,
PendingReason,
RecordEvidence,
TriageStatus,
)
from app.crossmatch.resolver import (
from uploader.app.crossmatch.resolver import (
_apply_redshift_check,
_resolve_by_radius_coordinate,
resolve,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_designation_rules.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from app.structured.designations.rules import match
from uploader.app.structured.designations.rules import match

RULE_CASES: list[tuple[str, tuple[str, str] | None]] = [
("2MASSJ16295276+3911433", ("CAT JHHMMSSss+DDMMSSs", "2MASS J16295276+3911433")),
Expand Down
8 changes: 4 additions & 4 deletions tests/test_server_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from fastapi.testclient import TestClient
from pydantic import BaseModel

import app.report as report
import server.history as history
import server.tasks as tasks
from server.main import app
import uploader.app.report as report
import uploader.history as history
import uploader.tasks as tasks
from uploader.cli import app


class FakeTaskForm(BaseModel):
Expand Down
20 changes: 10 additions & 10 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import pandas
import pytest

from app.gen.client import adminapi
from app.gen.client.adminapi import models, types
from app.interface import UploaderSource
from app.sources.csv import CSVSource
from app.upload import upload
from uploader.app.interface import UploaderSource
from uploader.app.sources.csv import CSVSource
from uploader.app.upload import upload
from uploader.clients.gen.client import adminapi
from uploader.clients.gen.client.adminapi import models, types


class StubPlugin(UploaderSource):
Expand Down Expand Up @@ -47,9 +47,9 @@ def mock_response[T: Any](resp: T) -> types.Response[T]:
)


@patch("app.upload.create_source")
@patch("app.upload.create_table")
@patch("app.upload.add_data")
@patch("uploader.app.upload.create_source")
@patch("uploader.app.upload.create_table")
@patch("uploader.app.upload.add_data")
def test_upload_with_csv_plugin(mock_add_data, mock_create_table, mock_create_source, mock_client):
mock_create_source_response = models.APIOkResponseCreateSourceResponse(
data=models.CreateSourceResponse(code="test_bibcode")
Expand Down Expand Up @@ -81,8 +81,8 @@ def test_upload_with_csv_plugin(mock_add_data, mock_create_table, mock_create_so
mock_add_data.sync_detailed.assert_called_once()


@patch("app.upload.create_source")
@patch("app.upload.create_table")
@patch("uploader.app.upload.create_source")
@patch("uploader.app.upload.create_table")
def test_plugin_stop_called_on_error(mock_create_table, mock_create_source, mock_client):
mock_create_source_response = models.APIOkResponseCreateSourceResponse(
data=models.CreateSourceResponse(code="test_bibcode")
Expand Down
1 change: 1 addition & 0 deletions uploader/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 4 additions & 4 deletions app/__init__.py → uploader/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from app.interface import (
from uploader.app.interface import (
BibcodeProvider,
DefaultTableNamer,
DescriptionProvider,
UploaderSource,
)
from app.log import logger
from app.tap import Constraint, TAPRepository
from app.upload import upload
from uploader.app.log import logger
from uploader.app.tap import Constraint, TAPRepository
from uploader.app.upload import upload

__all__ = [
"UploaderSource",
Expand Down
3 changes: 3 additions & 0 deletions uploader/app/crossmatch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from uploader.app.crossmatch.engine import run_crossmatch

__all__ = ["run_crossmatch"]
32 changes: 16 additions & 16 deletions app/crossmatch/engine.py → uploader/app/crossmatch/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@

from psycopg import sql

import app.report as report
from app import log
from app.crossmatch.models import (
import uploader.app.report as report
from uploader.app import log
from uploader.app.crossmatch.models import (
CrossmatchResult,
CrossmatchStatus,
Neighbor,
PendingReason,
RecordEvidence,
TriageStatus,
)
from app.crossmatch.resolver import Resolver
from app.display import format_table
from app.gen.client import adminapi
from app.gen.client.adminapi.api.default import set_crossmatch_results
from app.gen.client.adminapi.models.collided_status_payload import CollidedStatusPayload
from app.gen.client.adminapi.models.existing_status_payload import ExistingStatusPayload
from app.gen.client.adminapi.models.new_status_payload import NewStatusPayload
from app.gen.client.adminapi.models.record_triage_status import RecordTriageStatus
from app.gen.client.adminapi.models.set_crossmatch_results_request import (
from uploader.app.crossmatch.resolver import Resolver
from uploader.app.display import format_table
from uploader.app.storage import PgStorage
from uploader.app.upload import handle_call
from uploader.clients.gen.client import adminapi
from uploader.clients.gen.client.adminapi.api.default import set_crossmatch_results
from uploader.clients.gen.client.adminapi.models.collided_status_payload import CollidedStatusPayload
from uploader.clients.gen.client.adminapi.models.existing_status_payload import ExistingStatusPayload
from uploader.clients.gen.client.adminapi.models.new_status_payload import NewStatusPayload
from uploader.clients.gen.client.adminapi.models.record_triage_status import RecordTriageStatus
from uploader.clients.gen.client.adminapi.models.set_crossmatch_results_request import (
SetCrossmatchResultsRequest,
)
from app.gen.client.adminapi.models.statuses_payload import StatusesPayload
from app.gen.client.adminapi.types import UNSET, Unset
from app.storage import PgStorage
from app.upload import handle_call
from uploader.clients.gen.client.adminapi.models.statuses_payload import StatusesPayload
from uploader.clients.gen.client.adminapi.types import UNSET, Unset

C_M_S = 299792458

Expand Down
3 changes: 3 additions & 0 deletions uploader/app/crossmatch/layered/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from uploader.app.crossmatch.layered.resolver import LayeredResolver

__all__ = ["LayeredResolver"]
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from app.crossmatch.layered.models import (
from uploader.app.crossmatch.layered.models import (
PreliminaryCrossmatchStatus,
PreliminaryCrossmatchStatusColliding,
PreliminaryCrossmatchStatusExisting,
PreliminaryCrossmatchStatusNew,
)
from app.crossmatch.models import PendingReason, RecordEvidence
from uploader.app.crossmatch.models import PendingReason, RecordEvidence


def icrs_simple_resolver(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from app.crossmatch.layered.models import (
from uploader.app.crossmatch.layered.models import (
PreliminaryCrossmatchStatus,
PreliminaryCrossmatchStatusColliding,
PreliminaryCrossmatchStatusExisting,
PreliminaryCrossmatchStatusNew,
)
from app.crossmatch.models import PendingReason, RecordEvidence
from uploader.app.crossmatch.models import PendingReason, RecordEvidence


def name_resolver(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from app.crossmatch.layered.models import (
from uploader.app.crossmatch.layered.models import (
PreliminaryCrossmatchStatus,
PreliminaryCrossmatchStatusExisting,
PreliminaryCrossmatchStatusNew,
)
from app.crossmatch.models import PendingReason, RecordEvidence
from uploader.app.crossmatch.models import PendingReason, RecordEvidence

SIMILAR_TYPE_MAP = {
"G": {"ext", "?", "QSO"},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from app.crossmatch.layered.models import (
from uploader.app.crossmatch.layered.models import (
PreliminaryCrossmatchStatus,
PreliminaryCrossmatchStatusColliding,
PreliminaryCrossmatchStatusExisting,
PreliminaryCrossmatchStatusNew,
)
from app.crossmatch.models import PendingReason, RecordEvidence
from uploader.app.crossmatch.models import PendingReason, RecordEvidence


def pgc_resolver(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from app.crossmatch.layered.models import (
from uploader.app.crossmatch.layered.models import (
PreliminaryCrossmatchStatus,
PreliminaryCrossmatchStatusExisting,
PreliminaryCrossmatchStatusNew,
)
from app.crossmatch.models import PendingReason, RecordEvidence
from uploader.app.crossmatch.models import PendingReason, RecordEvidence


def redshift_resolver(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from app.crossmatch.layered import icrs, name, object_type, pgc, redshift
from app.crossmatch.layered.models import (
from uploader.app.crossmatch.layered import icrs, name, object_type, pgc, redshift
from uploader.app.crossmatch.layered.models import (
PreliminaryCrossmatchStatus,
PreliminaryCrossmatchStatusExisting,
PreliminaryCrossmatchStatusNew,
)
from app.crossmatch.models import CrossmatchResult, CrossmatchStatus, PendingReason, RecordEvidence, TriageStatus
from uploader.app.crossmatch.models import (
CrossmatchResult,
CrossmatchStatus,
PendingReason,
RecordEvidence,
TriageStatus,
)


def _preliminary_to_final(results: PreliminaryCrossmatchStatus, pending_reason: PendingReason) -> CrossmatchResult:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

from typing import Protocol

from app.crossmatch import layered
from app.crossmatch.models import (
from uploader.app.crossmatch import layered
from uploader.app.crossmatch.models import (
CrossmatchResult,
CrossmatchStatus,
Neighbor,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/interface.py → uploader/app/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pandas

from app.gen.client.adminapi import models
from uploader.clients.gen.client.adminapi import models


class UploaderSource(abc.ABC):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/lib/rawdata.py → uploader/app/lib/rawdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from psycopg import sql

from app import log
from app.storage import PgStorage
from uploader.app import log
from uploader.app.storage import PgStorage


def rawdata_batches(
Expand Down
File renamed without changes.
File renamed without changes.
Loading
Loading