Skip to content

Commit

Permalink
Add workflow for pypi release
Browse files Browse the repository at this point in the history
  • Loading branch information
Thecave3 authored Jan 30, 2025
2 parents 18c465b + bc70c37 commit 8ebc833
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 17 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Publish dApp package to PyPI

on:
push:
branches:
- main

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
if: github.repository == 'wineslab/dApp-library'

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'wineslab/dApp-library'
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/dapps
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign packages with Sigstore and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
if: github.repository == 'wineslab/dApp-library'

permissions:
contents: write
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest
if: github.repository == 'wineslab/dApp-library'

environment:
name: testpypi
url: https://test.pypi.org/p/dapps

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
4 changes: 2 additions & 2 deletions examples/spectrum_dapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def main(args, time_to_wait: float = 60.0):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="dApp example")
parser.add_argument('--ota', action='store_true', default=False, help="Specify if this is OTA or on Colosseum")
parser.add_argument('--link', type=str, default='posix', choices=[layer.value for layer in E3LinkLayer], help="Specify the link layer to be used")
parser.add_argument('--transport', type=str, default='uds', choices=[layer.value for layer in E3TransportLayer], help="Specify the transport layer to be used")
parser.add_argument('--link', type=str, default='zmq', choices=[layer.value for layer in E3LinkLayer], help="Specify the link layer to be used")
parser.add_argument('--transport', type=str, default='ipc', choices=[layer.value for layer in E3TransportLayer], help="Specify the transport layer to be used")
parser.add_argument('--save-iqs', action='store_true', default=False, help="Specify if this is data collection run or not. In the first case I/Q samples will be saved")
parser.add_argument('--control', action='store_true', default=False, help="Set whether to perform control of PRB")
parser.add_argument('--energy-gui', action='store_true', default=False, help="Set whether to enable the energy GUI")
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "dApps"
name = "dapps"
dynamic = ["version"]
description = 'A library for creating and connecting dApps to Open RAN units.'
readme = "README.md"
Expand Down Expand Up @@ -33,6 +33,7 @@ dependencies = [

[project.urls]
Homepage = "https://openrangym.com/ran-frameworks/dapps"
Package = "https://pypi.org/project/dapps/"
Source = "https://github.com/wineslab/dApp-library"
"Bug Tracker" = "https://github.com/wineslab/dApp-library/issues"

Expand All @@ -45,4 +46,13 @@ packages = ['src/dapp', 'src/e3interface', 'src/spectrum','src/visualization']
sources = ["src"]

[project.optional-dependencies]
option1 = ['influxdb_client']
network = ["pysctp"]
gui = ["flask", "flask-socketio", "matplotlib"]
api = ["influxdb_client"]
all = [
"pysctp",
"flask",
"flask-socketio",
"matplotlib",
"influxdb_client"
]
12 changes: 11 additions & 1 deletion src/e3interface/e3_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import socket
import zmq
import sctp
from .e3_logging import e3_logger, LOG_DIR


Expand Down Expand Up @@ -208,6 +207,17 @@ def __init__(self, transport_layer: E3TransportLayer):
def _create_socket(self):
match self.transport_layer:
case E3TransportLayer.SCTP:
try:
import sctp
except ModuleNotFoundError:
e3_logger.critical(
"SCTP selected as transport layer, but the optional dependency 'pysctp' is not installed.\n"
"Fix this by running:\n\n"
" pip install 'dApps[network]' # OR\n"
" pip install 'dApps[all]'\n",
exc_info=True
)
exit(-1)
sock = sctp.sctpsocket_tcp(socket.AF_INET)
case E3TransportLayer.TCP:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand Down
14 changes: 12 additions & 2 deletions src/visualization/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import threading
from flask import Flask, render_template
from flask_socketio import SocketIO
try:
from flask import Flask, render_template
from flask_socketio import SocketIO
except ModuleNotFoundError:
print(
"Optional dependencies for GUI not installed.\n"
"Fix this by running:\n\n"
" pip install 'dApps[gui]' # OR\n"
" pip install 'dApps[all]'\n",
exc_info=True
)
exit(-1)
import numpy as np

class DemoGui:
Expand Down
12 changes: 11 additions & 1 deletion src/visualization/energy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import numpy as np
import matplotlib
try:
import matplotlib
except ModuleNotFoundError:
print(
"Optional dependencies for GUI not installed.\n"
"Fix this by running:\n\n"
" pip install 'dApps[gui]' # OR\n"
" pip install 'dApps[all]'\n",
exc_info=True
)
exit(-1)
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

Expand Down
16 changes: 11 additions & 5 deletions src/visualization/grafana.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import configparser
try:
import configparser
from influxdb_client import InfluxDBClient, Point
except ImportError as e:
print(e.msg)
print("Please install influxdb_client to use this class")
exit(-1)
except [ImportError, ModuleNotFoundError] as e:
print(e.msg)
print(
"Optional dependencies for API not installed.\n"
"Fix this by running:\n\n"
" pip install 'dApps[api]' # OR\n"
" pip install 'dApps[all]'\n",
exc_info=True
)
exit(-1)
import atexit
import logging

Expand Down
15 changes: 13 additions & 2 deletions src/visualization/influx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import configparser
from influxdb_client import InfluxDBClient, Point
try:
import configparser
from influxdb_client import InfluxDBClient, Point
except [ImportError, ModuleNotFoundError] as e:
print(e.msg)
print(
"Optional dependencies for API not installed.\n"
"Fix this by running:\n\n"
" pip install 'dApps[api]' # OR\n"
" pip install 'dApps[all]'\n",
exc_info=True
)
exit(-1)
import time
import atexit
import numpy as np
Expand Down
14 changes: 12 additions & 2 deletions src/visualization/iq.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import numpy as np
import matplotlib
try:
import matplotlib
except ModuleNotFoundError:
print(
"Optional dependencies for GUI not installed.\n"
"Fix this by running:\n\n"
" pip install 'dApps[gui]' # OR\n"
" pip install 'dApps[all]'\n",
exc_info=True
)
exit(-1)
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import numpy as np
import os

print(os.environ.get('DISPLAY'))
Expand Down

0 comments on commit 8ebc833

Please sign in to comment.