Skip to content

Commit

Permalink
feat: complete rename
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto-abarzua committed Nov 15, 2023
1 parent 12697c0 commit bc63a99
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 45 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/controller-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
CONTROLLER_WEBSOCKET_PORT: ${{ vars.CONTROLLER_WEBSOCKET_PORT }}
CONTROLLER_SERVER_PORT: ${{ vars.CONTROLLER_SERVER_PORT }}
BACKEND_HTTP_PORT: ${{ vars.BACKEND_HTTP_PORT }}
CONTROLLER_PDM_PUBLISH_PASSWORD: ${{ secrets.CONTROLLER_PDM_PUBLISH_PASSWORD }}
CONTROLLER_PDM_PUBLISH_USERNAME: ${{ secrets.CONTROLLER_PDM_PUBLISH_USERNAME }}
CONTROLLER_PDM_OVERRIDE_VERSION: 'none'
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -37,6 +40,10 @@ jobs:

- name: Run Firmware and Controller Tests
run: ./manage.py test

- name: Publish Controller Package
if: github.ref == 'refs/heads/main'
run: ./manage.py publish-controller

- name: Stop and remove containers
if: always()
Expand Down
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ COPY ./pdm.lock ./pdm.lock

COPY . .

RUN pdm install

RUN chmod +x ./entrypoint.sh

Expand Down
9 changes: 7 additions & 2 deletions backend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/sh


echo "Installing dependecies (required for editable mode)"
pdm install --dev
# check if BACKEND_UPDATE_RIBOT_CONTROLLER is set to 'true'
if [ "$BACKEND_UPDATE_RIBOT_CONTROLLER" = "true" ]; then

echo "Updating ribot-controller to latest"
echo "Updating ribot-controller to latest"
pdm update ribot-controller
fi


exec "$@"
14 changes: 8 additions & 6 deletions backend/pdm.lock

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

7 changes: 6 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ dependencies = [
"fastapi>=0.101.1",
"uvicorn>=0.23.2",
"numpy>=1.20",
"ribot-controller>=0.3.4",
]
requires-python = ">=3.11"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm.dev-dependencies]
dev = [
"-e file:///${PROJECT_ROOT}/controller#egg=ribot",
"black>=23.11.0",
"isort>=5.12.0",
"flake8>=6.0.0",
Expand All @@ -34,3 +34,8 @@ type_check = "mypy src"
format = {composite = ["isort", "black"]}
lint = {composite = ["pure_lint", "type_check"]}


[mypy]
ignore_missing_imports = "True"
disallow_untyped_defs = "True"
mypy_path = "src"
1 change: 0 additions & 1 deletion backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from utils.general import start_controller, stop_controller



@asynccontextmanager
async def controller_lifespan(_: FastAPI): # type: ignore # noqa: ANN201
start_controller()
Expand Down
15 changes: 14 additions & 1 deletion controller/pdm.lock

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

13 changes: 9 additions & 4 deletions controller/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

[build-system]
requires = ["pdm-backend","requests>=2.31","packaging>=23.2"]
build-backend = "pdm.backend"

[project]
name = "ribot-controller"
dynamic = ["version"]
Expand All @@ -21,16 +25,17 @@ dependencies = [
"asyncio>=3.4.3",
"rich>=13.4.2",
]
requires-python = ">=3.11"
requires-python = ">=3.9"
license = {text = "MIT"}

[tool.pdm.version]
source = "call"
getter = "src.ribot.utils.version:get_version"

[tool.pdm]
[tool.pdm.files]
"ribot/py.typed" = "src/ribot/py.typed"

[tool.pdm.version]
source = "call"
getter = "ribot.utils.version.get_version()"


[tool.pdm.scripts]
Expand Down
1 change: 1 addition & 0 deletions controller/src/ribot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.3"
2 changes: 1 addition & 1 deletion controller/src/ribot/control/controller_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _start(self) -> None:
self.controller.stop()
return
console.log(f"Starting websocket server on port {self.port}", style="setup")
self.server = asyncio.get_event_loop().run_until_complete(start_server)
self.server = asyncio.get_event_loop().run_until_complete(start_server) # type: ignore

asyncio.get_event_loop().run_forever()

Expand Down
22 changes: 16 additions & 6 deletions controller/src/ribot/utils/version.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import requests
# mypy: ignore-errors
import os
from typing import Any

import requests # type: ignore # noqa: F401
from packaging import version

def get_version() -> str:
return '0.0.3'

def get_version(*args: Any, **kwargs: Any) -> str:
url = "https://pypi.org/pypi/ribot-controller/json"

override_version = os.getenv("PDM_OVERRIDE_VERSION", "")

if "none" in override_version.lower():
override_version = None

if override_version is not None:
return override_version

response = requests.get(url)
if response.status_code == 200:
package_info = response.json()
Expand All @@ -15,10 +27,8 @@ def get_version() -> str:
print(f"Current version: {current_version}")

# Increment the minor version
new_version = version.Version(f"{current_version.major}.{current_version.minor + 1}.{current_version.micro}")
new_version = version.Version(f"{current_version.major}.{current_version.minor}.{current_version.micro+1}")

return str(new_version)
else:
raise Exception("Failed to retrieve package information")


1 change: 1 addition & 0 deletions docker_services/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
environment:
- BACKEND_HTTP_PORT
- CONTROLLER_WEBSOCKET_PORT
- BACKEND_UPDATE_RIBOT_CONTROLLER
- CONTROLLER_SERVER_PORT

volumes:
Expand Down
1 change: 1 addition & 0 deletions docker_services/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ services:
- PDM_PUBLISH_USERNAME=$CONTROLLER_PDM_PUBLISH_USERNAME
- PDM_PUBLISH_PASSWORD=$CONTROLLER_PDM_PUBLISH_PASSWORD
- PRINT_STATUS
- PDM_OVERRIDE_VERSION=$CONTROLLER_PDM_OVERRIDE_VERSION=None
Loading

0 comments on commit bc63a99

Please sign in to comment.