Skip to content

Commit

Permalink
renamed package to ranlibx
Browse files Browse the repository at this point in the history
  • Loading branch information
AmeerArsala committed Sep 30, 2024
1 parent 72430db commit dc09df9
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 20 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

4 changes: 2 additions & 2 deletions pipelight.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{
Expand Down
2 changes: 1 addition & 1 deletion pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions ranx/api/auth.py → ranlibx/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
6 changes: 3 additions & 3 deletions ranx/api/main.py → ranlibx/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]"})

Expand Down
1 change: 1 addition & 0 deletions ranlibx/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ranlibx.cli.main import app
10 changes: 5 additions & 5 deletions ranx/cli/main.py → ranlibx/cli/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ranx/constants.py → ranlibx/constants.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ranx/state.py → ranlibx/state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum

from ranx import server
from ranlibx import server


class AuthFlowState(Enum):
Expand Down
1 change: 0 additions & 1 deletion ranx/cli/__init__.py

This file was deleted.

4 changes: 4 additions & 0 deletions scripts/upload-anaconda.sh
Original file line number Diff line number Diff line change
@@ -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:
42 changes: 42 additions & 0 deletions scripts/upload-prefixdev.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit dc09df9

Please sign in to comment.