From dc09df9d68c1a13e2f0ceff282790526a4b8bac6 Mon Sep 17 00:00:00 2001 From: Ameer Arsala <ameer.arsala03@gmail.com> Date: Sun, 29 Sep 2024 19:30:28 -0700 Subject: [PATCH] renamed package to ranlibx --- .github/workflows/publish.yml | 18 ++++++++++ pipelight.hcl | 4 +-- pixi.lock | 2 +- pyproject.toml | 8 ++--- {ranx => ranlibx}/__init__.py | 0 {ranx => ranlibx}/api/__init__.py | 0 {ranx => ranlibx}/api/auth.py | 4 +-- {ranx => ranlibx}/api/main.py | 6 ++-- ranlibx/cli/__init__.py | 1 + {ranx => ranlibx}/cli/main.py | 10 +++--- {ranx => ranlibx}/cli/subcmds/__init__.py | 0 {ranx => ranlibx}/cli/subcmds/install.py | 0 {ranx => ranlibx}/constants.py | 2 +- {ranx => ranlibx}/server.py | 0 {ranx => ranlibx}/state.py | 2 +- ranx/cli/__init__.py | 1 - scripts/upload-anaconda.sh | 4 +++ scripts/upload-prefixdev.py | 42 +++++++++++++++++++++++ 18 files changed, 84 insertions(+), 20 deletions(-) rename {ranx => ranlibx}/__init__.py (100%) rename {ranx => ranlibx}/api/__init__.py (100%) rename {ranx => ranlibx}/api/auth.py (92%) rename {ranx => ranlibx}/api/main.py (92%) create mode 100644 ranlibx/cli/__init__.py rename {ranx => ranlibx}/cli/main.py (89%) rename {ranx => ranlibx}/cli/subcmds/__init__.py (100%) rename {ranx => ranlibx}/cli/subcmds/install.py (100%) rename {ranx => ranlibx}/constants.py (77%) rename {ranx => ranlibx}/server.py (100%) rename {ranx => ranlibx}/state.py (95%) delete mode 100644 ranx/cli/__init__.py create mode 100644 scripts/upload-anaconda.sh create mode 100644 scripts/upload-prefixdev.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 15ee47e..dcadbca 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,3 +33,21 @@ jobs: env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + + # Now for uploading the conda packages + # - name: Install rattler-build + # run: pixi global install rattler-build + # + # - name: Build it for conda with rattler-build + # run: rattler-build [TODO] + # + # - name: Upload to Prefix + # run: python3 scripts/upload-prefixdev.py [TODO - PUT .conda HERE] $PREFIX_TOKEN + # env: + # PREFIX_TOKEN: ${{ secrets.PREFIX_DEV_TOKEN }} + # + # - name: Upload to Anaconda + # run: anaconda upload [TODO - put .conda HERE] + # env: + # ANACONDA_TOKEN: ${{secrets.ANACONDA_TOKEN}} + diff --git a/pipelight.hcl b/pipelight.hcl index 8d68b65..eb51318 100644 --- a/pipelight.hcl +++ b/pipelight.hcl @@ -4,11 +4,11 @@ pipelines = [ steps = [ { name = "format" - commands = ["ruff format ranx"] + commands = ["ruff format ranlibx"] }, { name = "lint" - commands = ["ruff check ranx --fix"] + commands = ["ruff check ranlibx --fix"] } ] triggers = [{ diff --git a/pixi.lock b/pixi.lock index fa4bdef..1a5274e 100644 --- a/pixi.lock +++ b/pixi.lock @@ -2608,7 +2608,7 @@ packages: name: ranlibx version: 0.0.2 path: . - sha256: 4540e8d7d16431f21e638195f2ae577c2475d5ceabd9644670cb69240d7cdcc0 + sha256: 1adc6bda08b6acadd698ac22041f062df2846efc7e10cf6793d76e251d18f157 requires_dist: - fastapi>=0.112.2,<0.113 - typer>=0.12.5,<0.13 diff --git a/pyproject.toml b/pyproject.toml index b53996f..2c56f1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,14 +15,14 @@ dependencies = [ requires-python = ">= 3.9" [project.scripts] -ranx = "ranx.cli.main:app" +ranx = "ranlibx.cli.main:app" [build-system] build-backend = "hatchling.build" requires = ["hatchling"] -[tool.hatch.build.targets.wheel] -packages = ["ranx"] # account for discrepancy between ranlibx and ranx +#[tool.hatch.build.targets.wheel] +#packages = ["ranx"] # account for discrepancy between ranlibx and ranx [tool.pixi.project] channels = ["conda-forge"] @@ -37,7 +37,7 @@ hatch = "*" ruff = ">=0.6.8,<0.7" # [tool.pixi.tasks] -## ranx = "python3 ranx/cli/main.py" +## ranx = "python3 ranlibx/cli/main.py" [tool.pixi.feature.devdeps.tasks] build = "hatch build ./dist" diff --git a/ranx/__init__.py b/ranlibx/__init__.py similarity index 100% rename from ranx/__init__.py rename to ranlibx/__init__.py diff --git a/ranx/api/__init__.py b/ranlibx/api/__init__.py similarity index 100% rename from ranx/api/__init__.py rename to ranlibx/api/__init__.py diff --git a/ranx/api/auth.py b/ranlibx/api/auth.py similarity index 92% rename from ranx/api/auth.py rename to ranlibx/api/auth.py index a136e63..d1ba496 100644 --- a/ranx/api/auth.py +++ b/ranlibx/api/auth.py @@ -5,8 +5,8 @@ from fastapi import APIRouter, HTTPException, status from pydantic import BaseModel, Field -from ranx.constants import RAN_AUTH_TOKEN_FILEPATH_JSON -from ranx.state import AUTH_FLOW_STATE, AuthFlowState, set_auth_flow_state +from ranlibx.constants import RAN_AUTH_TOKEN_FILEPATH_JSON +from ranlibx.state import AUTH_FLOW_STATE, AuthFlowState, set_auth_flow_state # Prefix: /auth router = APIRouter(tags=["Authentication"]) diff --git a/ranx/api/main.py b/ranlibx/api/main.py similarity index 92% rename from ranx/api/main.py rename to ranlibx/api/main.py index 2c398b7..57446c7 100644 --- a/ranx/api/main.py +++ b/ranlibx/api/main.py @@ -16,9 +16,9 @@ from fastapi.responses import JSONResponse from pydantic import ValidationError -from ranx.api import auth -from ranx.constants import RAN_DOMAIN # ran.so -from ranx.state import kill_server +from ranlibx.api import auth +from ranlibx.constants import RAN_DOMAIN # ran.so +from ranlibx.state import kill_server app = FastAPI(title="RANx (Global)", contact={"name": "Anemo AI", "email": "support@anemo.ai"}) diff --git a/ranlibx/cli/__init__.py b/ranlibx/cli/__init__.py new file mode 100644 index 0000000..f9a1ed0 --- /dev/null +++ b/ranlibx/cli/__init__.py @@ -0,0 +1 @@ +from ranlibx.cli.main import app diff --git a/ranx/cli/main.py b/ranlibx/cli/main.py similarity index 89% rename from ranx/cli/main.py rename to ranlibx/cli/main.py index 97187ff..89d9954 100644 --- a/ranx/cli/main.py +++ b/ranlibx/cli/main.py @@ -1,10 +1,10 @@ import typer import uvicorn -from ranx import server -from ranx.cli.subcmds import install -from ranx.server import UvicornServerProcess -from ranx.state import AuthFlowState, kill_server, set_auth_flow_state +from ranlibx import server +from ranlibx.cli.subcmds import install +from ranlibx.server import UvicornServerProcess +from ranlibx.state import AuthFlowState, kill_server, set_auth_flow_state # Dev / Testing stuff # import asyncio @@ -49,7 +49,7 @@ def close_auth_server(verbose: bool = False): # # print("Starting Server...") # config = uvicorn.Config( -# "ranx.api.main:app", +# "ranlibx.api.main:app", # host="0.0.0.0", # port=8000, # log_level="critical" diff --git a/ranx/cli/subcmds/__init__.py b/ranlibx/cli/subcmds/__init__.py similarity index 100% rename from ranx/cli/subcmds/__init__.py rename to ranlibx/cli/subcmds/__init__.py diff --git a/ranx/cli/subcmds/install.py b/ranlibx/cli/subcmds/install.py similarity index 100% rename from ranx/cli/subcmds/install.py rename to ranlibx/cli/subcmds/install.py diff --git a/ranx/constants.py b/ranlibx/constants.py similarity index 77% rename from ranx/constants.py rename to ranlibx/constants.py index 564ef18..3970d23 100644 --- a/ranx/constants.py +++ b/ranlibx/constants.py @@ -1,6 +1,6 @@ from pathlib import Path -RANX_PROJECT_ROOT: str = str(Path(__file__).parent.parent) +RANLIBX_PROJECT_ROOT: str = str(Path(__file__).parent.parent) LIB_ROOT: str = str(Path(__file__).parent) RAN_DOMAIN: str = "ran.so" diff --git a/ranx/server.py b/ranlibx/server.py similarity index 100% rename from ranx/server.py rename to ranlibx/server.py diff --git a/ranx/state.py b/ranlibx/state.py similarity index 95% rename from ranx/state.py rename to ranlibx/state.py index ae63825..c43d106 100644 --- a/ranx/state.py +++ b/ranlibx/state.py @@ -1,6 +1,6 @@ from enum import Enum -from ranx import server +from ranlibx import server class AuthFlowState(Enum): diff --git a/ranx/cli/__init__.py b/ranx/cli/__init__.py deleted file mode 100644 index 2920872..0000000 --- a/ranx/cli/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ranx.cli.main import app diff --git a/scripts/upload-anaconda.sh b/scripts/upload-anaconda.sh new file mode 100644 index 0000000..2e4e53a --- /dev/null +++ b/scripts/upload-anaconda.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Note: the reason this is here is because ranx should not go on conda-forge as it is not meant to be explicitly installed by the user; instead, it is more of a system dependency. +# TODO: diff --git a/scripts/upload-prefixdev.py b/scripts/upload-prefixdev.py new file mode 100644 index 0000000..f06a609 --- /dev/null +++ b/scripts/upload-prefixdev.py @@ -0,0 +1,42 @@ +import sys + +import hashlib +from pathlib import Path + +import httpx + + +CHANNEL_NAME = "anemo" +channel: str = f"https://prefix.dev/api/v1/upload/{CHANNEL_NAME}" + + +def upload(fn, token: str): + data = fn.read_bytes() + + # if larger than 100mb, skip + if len(data) > 100 * 1024 * 1024: + print("Skipping", fn, "because it is too large") + return + + name = fn.name + sha256 = hashlib.sha256(data).hexdigest() + headers = { + "X-File-Name": name, + "X-File-SHA256": sha256, + "Authorization": f"Bearer {token}", + "Content-Length": str(len(data) + 1), + "Content-Type": "application/octet-stream", + } + + r = httpx.post(channel, data=data, headers=headers) + print(f"Uploaded package {name} with status {r.status_code}") + + +if __name__ == "__main__": + if len(sys.argv) > 2: + package = Path(sys.argv[1]) # get path + token: str = f"pfx_vr2XPfxpByKvGVhzr{sys.argv[2]}" + upload(package, token) + else: + print("Usage: upload-prefixdev.py <package> <token>") + sys.exit(1)