Skip to content
Open
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
10 changes: 0 additions & 10 deletions .dockerignore

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/build.yaml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: E2E wheel

on:
push:
branches: [main, master]
pull_request:

jobs:
build-wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- uses: actions/setup-node@v4
with:
node-version: "20"

- run: corepack enable

- name: Install Python deps
run: make install-dev

- name: Run codegen
run: make gen

- name: Build wheel
run: uv build

- uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl

verify:
needs: build-wheel
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
runs-on: ${{ matrix.os }}
steps:
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"

- uses: actions/download-artifact@v4
with:
name: wheel
path: dist

- name: Verify uploader
run: |
set -e
WHEEL=$(ls dist/*.whl | head -n1)
uvx --python 3.13 --from "$WHEEL" uploader --no-browser &
PID=$!
sleep 8
curl -sf http://127.0.0.1:8000/api/tasks >/dev/null
curl -sf http://127.0.0.1:8000/ >/dev/null
kill $PID
52 changes: 22 additions & 30 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
name: Release image
name: Release wheel

on:
workflow_dispatch:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
contents: write
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install deps
- uses: actions/setup-node@v4
with:
node-version: "20"

- run: corepack enable

- name: Install Python deps
run: make install-dev

- name: Run codegen
run: make gen

- name: Set up Docker runtime
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

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

- name: Build and push image
uses: docker/build-push-action@v6
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }}
${{ env.IMAGE_NAME }}:latest
tag_name: build-${{ github.sha }}
name: Wheel ${{ github.sha }}
files: dist/*.whl
generate_release_notes: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ pyrightconfig.json

.vizier_cache

server/static/

node_modules/

history.jsonl
12 changes: 0 additions & 12 deletions Dockerfile

This file was deleted.

5 changes: 4 additions & 1 deletion app/sources/vizier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
from astroquery import vizier

import app
import server.paths as paths
from app.gen.client.adminapi import models, types

VIZIER_URL = "https://vizier.cds.unistra.fr/viz-bin/votable/-tsv"

_DEFAULT_VIZIER_CACHE = str(paths.DATA_DIR / "vizier_cache")


def _coerce_row_to_schema(
row_dict: dict[str, object],
Expand Down Expand Up @@ -58,7 +61,7 @@ def __init__(
self,
catalog_name: str,
table_name: str,
cache_path: str = ".vizier_cache/",
cache_path: str = _DEFAULT_VIZIER_CACHE,
batch_size: int = 100,
):
self.cache_path = cache_path
Expand Down
5 changes: 4 additions & 1 deletion app/sources/vizier_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
from astroquery import vizier

import app
import server.paths as paths
from app.gen.client.adminapi import models, types

_DEFAULT_VIZIER_CACHE = str(paths.DATA_DIR / "vizier_cache")


def _sanitize_filename(string: str) -> str:
return (
Expand Down Expand Up @@ -59,7 +62,7 @@ def __init__(
table_name: str,
index_column: str,
*constraints: str,
cache_path: str = ".vizier_cache/",
cache_path: str = _DEFAULT_VIZIER_CACHE,
batch_size: int = 1000,
):
if len(constraints) % 3 != 0:
Expand Down
21 changes: 21 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess
from pathlib import Path

from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class CustomHook(BuildHookInterface):
PLUGIN_NAME = "custom"

def initialize(self, version: str, build_data: dict) -> None:
frontend_dir = Path(self.root) / "frontend"
subprocess.run(
["yarn", "install", "--frozen-lockfile"],
cwd=frontend_dir,
check=True,
)
subprocess.run(
["yarn", "build"],
cwd=frontend_dir,
check=True,
)
5 changes: 0 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ fix-frontend:
@output=$$(cd frontend && yarn run --silent prettier --write src 2>&1) || { echo "$$output"; exit 1; }
@output=$$(cd frontend && yarn run --silent eslint --fix src 2>&1) || { echo "$$output"; exit 1; }

# only for mac as this is faster
build:
docker build . \
--platform linux/arm64

new-branch:
@read -p "Branch name: " branch_name && \
branch_name=$${branch_name// /-} && \
Expand Down
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "uploader"
name = "hyperleda-uploader"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
Expand All @@ -18,6 +22,18 @@ dependencies = [
"psycopg[binary]>=3.2.0",
]

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

[tool.hatch.build.targets.wheel]
packages = ["server", "app"]

[tool.hatch.build.targets.wheel.force-include]
"frontend/dist" = "server/static"

[tool.hatch.build.hooks.custom]
path = "hatch_build.py"

[dependency-groups]
dev = [
"ruff~=0.15.0",
Expand Down Expand Up @@ -121,6 +137,7 @@ reportImplicitAbstractClass = "error"
exclude = [
"frontend/**",
"app/gen/**",
"hatch_build.py",
".venv/**"
]

Expand Down
19 changes: 19 additions & 0 deletions server/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import argparse
import threading
import webbrowser

import uvicorn


def main() -> None:
parser = argparse.ArgumentParser(description="HyperLEDA Uploader")
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--host", type=str, default="127.0.0.1")
parser.add_argument("--no-browser", action="store_true")
args = parser.parse_args()

if not args.no_browser:
url = f"http://{args.host}:{args.port}/"
threading.Timer(1.5, webbrowser.open, args=[url]).start()

uvicorn.run("server.main:app", host=args.host, port=args.port)
6 changes: 3 additions & 3 deletions server/credentials.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pathlib

import dotenv

ENV_PATH = pathlib.Path(".env")
import server.paths as paths

ENV_PATH = paths.DATA_DIR / ".env"


def save_credentials(db_user: str, db_password: str) -> None:
Expand Down
5 changes: 4 additions & 1 deletion server/forms/upload_vizier.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
from pydantic import BaseModel, Field

import app.report as report
import server.paths as paths
from app.endpoints import env_map
from app.gen.client import adminapi
from app.sources.vizier import VizierSource
from app.upload import upload_for_web

_DEFAULT_VIZIER_CACHE = str(paths.DATA_DIR / "vizier_cache")


class UploadVizierForm(BaseModel):
catalog_name: str = Field(..., title="VizieR catalog name")
source_table_name: str = Field(..., title="VizieR table name")
cache_path: str = Field(default=".vizier_cache/", title="Cache path")
cache_path: str = Field(default=_DEFAULT_VIZIER_CACHE, title="Cache path")
batch_size: int = Field(default=100, title="Batch size", ge=1)
table_name: str = Field(
default="",
Expand Down
5 changes: 4 additions & 1 deletion server/forms/upload_vizier_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
from pydantic import BaseModel, Field

import app.report as report
import server.paths as paths
from app.endpoints import env_map
from app.gen.client import adminapi
from app.sources.vizier_v2 import VizierV2Source
from app.upload import upload_for_web
from server.forms.upload_base import UploadBaseForm

_DEFAULT_VIZIER_CACHE = str(paths.DATA_DIR / "vizier_cache")


class UploadVizierV2Form(UploadBaseForm):
catalog_name: str = Field(..., title="VizieR catalog name")
Expand All @@ -20,7 +23,7 @@ class UploadVizierV2Form(UploadBaseForm):
title="Constraints",
description="Provide as repeating triples: column, operator, value.",
)
cache_path: str = Field(default=".vizier_cache/", title="Cache path")
cache_path: str = Field(default=_DEFAULT_VIZIER_CACHE, title="Cache path")
batch_size: int = Field(default=1000, title="Batch size", ge=1)


Expand Down
Loading
Loading