Skip to content

Commit

Permalink
Merge pull request #47 from HEnquist/include_env_files
Browse files Browse the repository at this point in the history
Include env files
  • Loading branch information
HEnquist authored Jan 8, 2024
2 parents f45aeb4 + 20dc03c commit a4a4c52
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 64 deletions.
49 changes: 45 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@ name: npm build
on: [push]

jobs:

read_fe_tag:
runs-on: ubuntu-latest
outputs:
fe_tag: ${{ steps.fe_tag_step.outputs.fe_tag }}
steps:
- uses: actions/checkout@v3
- name: Get CamillaGUI tag from versions.yml
id: fe_tag_step
run: |
FE_TAG=$(sed -n 's/camillagui_tag: \(.*\)$/\1/p' release_automation/versions.yml)
echo "fe_tag=$FE_TAG"
echo "fe_tag=$FE_TAG" >> "$GITHUB_OUTPUT"
build_fe:
runs-on: ubuntu-latest
needs: read_fe_tag
steps:
- uses: actions/checkout@v3
name: Check out frontend ${{ needs.read_fe_tag.outputs.fe_tag }}
with:
repository: HEnquist/camillagui
ref: v2.0.0
ref: ${{ needs.read_fe_tag.outputs.fe_tag }}
- name: Build and publish
uses: actions/setup-node@v3
with:
Expand All @@ -30,15 +46,40 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.12'
- name: Run python tests
run: python3 -m unittest discover -p "*_test.py"

- name: Install template render dependencies
run: |
python -m pip install --upgrade pip
pip install jinja2 PyYAML
- name: Render scripts from templates
run: python -m release_automation.render_env_files

- name: Clean up
run: rm -rf release_automation

- name: Download frontend
uses: actions/download-artifact@v3
- name: Upload all

- name: Create zip
run: zip -r camillagui.zip *

- name: Upload all as artifact
uses: actions/upload-artifact@v3
with:
name: camillagui-backend
path: |
.
!.git*
!.git*
- name: Upload binaries to release
if: contains(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: camillagui.zip
asset_name: camillagui.zip
tag: ${{ github.ref }}
42 changes: 0 additions & 42 deletions .github/workflows/publish.yml

This file was deleted.

42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ The complete GUI is made up of two parts:
- a backend based on AIOHTTP: https://docs.aiohttp.org/en/stable/

## Setting up
### Install gui server
Go to "Releases": https://github.com/HEnquist/camillagui-backend/releases
Download the zip-file ("camillagui.zip") for the latest release. This includes both the backend and the frontend.

Unzip the file and edit `config/camillagui.yml` as needed, see [Configuration](#configuration).

### Python dependencies
The gui requires the following Python packages:
- Python 3.8 or later
- websocket-client (required by pycamilladsp)
- jsonschema (required by pycamilladsp-plot)
- aiohttp
The Python dependencies are listed in three different files,
for use with different Python package/environment managers.
- `cdsp_conda.yml` for [conda](https://conda.io/).
- `requirements.txt` for [pip](https://pip.pypa.io/), often combined with an environment manager such as [venv](https://docs.python.org/3/library/venv.html).
- `pyproject.toml` for [Poetry](https://python-poetry.org).

### CamillaDSP Python libraries
You need both the CamillaDSP companion python libraries:
- `pycamilladsp` version 2.0.0 from https://github.com/HEnquist/pycamilladsp
- `pycamilladsp-plot` version 2.0.0 from https://github.com/HEnquist/pycamilladsp-plot

### Prepare the Python environment
The easiest way to get the Python environment prepared is to use the setup scripts from
Expand All @@ -29,11 +31,6 @@ If doing a manual installation, there are many ways of installing Python and set
Please see the [documentation for pycamilladsp](https://henquist.github.io/pycamilladsp/install/#installing)
for more information.

### Install gui server
Go to "Releases": https://github.com/HEnquist/camillagui-backend/releases
Download the zip-file ("camillagui.zip") for the latest release. This includes both the backend and the frontend.

Unzip the file, and edit `config/camillagui.yml` if needed.

## Configuration

Expand All @@ -57,7 +54,7 @@ supported_playback_types: null (*)
```
The options marked `(*)` are optional. If left out the default values listed above will be used. The included configuration has CamillaDSP running on the same machine as the backend, with the websocket server enabled at port 1234. The web interface will be served on port 5000. It is possible to run the gui and CamillaDSP on different machines, just point the `camilla_host` to the right address.

**Warning**: By default the backend will bind to all networks and this may be insecure. Make sure to change the `bind_address` if you want it to be reachable only on specific network interface(s) and/or to set your firewall to block external (internet) access to this backend.
**Warning**: By default the backend will bind to all network interfaces. This makes the gui available on all networks the system is connected to, which may be insecure. Make sure to change the `bind_address` if you want it to be reachable only on specific network interface(s) and/or to set your firewall to block external (internet) access to this backend.

The settings for config_dir and coeff_dir point to two folders where the backend has permissions to write files. This is provided to enable uploading of coefficients and config files from the gui.

Expand Down Expand Up @@ -150,7 +147,20 @@ The gui should now be available at: http://localhost:5000/gui/index.html

If accessing the gui from a different machine, replace "localhost" by the IP or hostname of the machine running the gui server.

### Running the tests (for developers)

## Development
### Render the environment files
This repository contains [jinja](https://palletsprojects.com/p/jinja/) templates used to create the Python environment files.
The templates are stored in `release_automation/templates/`.

To render the templates, install the dependencies `PyYAML` and `jinja2` and run the Python script `render_env_files.py`:
```sh
python -m release_automation.render_env_files
```
When rendering, the versions of the Python dependencies are taken from the file `release_automation/versions.yml`.
The backend version is read from `backend/version.py`.

### Running the tests

```sh
python -m unittest discover -p "*_test.py"
Expand Down
2 changes: 1 addition & 1 deletion backend/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = (2, 0, 0)
VERSION = (2, 0, 1)
2 changes: 1 addition & 1 deletion config/camillagui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
camilla_host: "127.0.0.1"
camilla_port: 1234
bind_address: "0.0.0.0"
port: 5005
port: 5000
config_dir: "~/camilladsp/configs"
coeff_dir: "~/camilladsp/coeffs"
default_config: "~/camilladsp/default_config.yml"
Expand Down
Empty file added release_automation/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions release_automation/render_env_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import yaml
import os

from jinja2 import Environment, FileSystemLoader

from backend.version import VERSION

script_dir = os.path.dirname(__file__)

with open(os.path.join(script_dir, "versions.yml")) as f:
versions = yaml.safe_load(f)

versions["backend_version"] = ".".join(str(v) for v in VERSION)

environment = Environment(loader=FileSystemLoader(os.path.join(script_dir, "templates/")))

filenames = [
"requirements.txt",
"cdsp_conda.yml",
"pyproject.toml",
]

for filename in filenames:
t = environment.get_template(filename + ".j2")

# render and write
rendered = t.render(versions)
with open(filename, mode="w", encoding="utf-8") as f:
f.write(rendered)
11 changes: 11 additions & 0 deletions release_automation/templates/cdsp_conda.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{# Template for conda environment file -#}
---
name: camillagui
channels:
- conda-forge
dependencies:
- pip
- aiohttp
- pip:
- "git+https://github.com/HEnquist/pycamilladsp.git@{{ pycamilladsp_tag }}"
- "camilladsp-plot[plot]@git+https://github.com/HEnquist/pycamilladsp-plot.git@{{ pycamilladsp_plot_tag }}"
20 changes: 20 additions & 0 deletions release_automation/templates/pyproject.toml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "camillagui-backend"
version = "{{ backend_version }}"
description = "Backend server for CamillaGUI"
authors = ["Henrik Enquist <henrik[email protected]>"]
license = "GPLv3"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
websocket-client = "^1.6.4"
jsonschema = "^4.20.0"
aiohttp = "^3.9.0"
numpy = "^1.26.0"
camilladsp = {git = "https://github.com/HEnquist/pycamilladsp.git", rev = "{{ pycamilladsp_tag }}"}
camilladsp-plot = {git = "https://github.com/HEnquist/pycamilladsp-plot.git", rev = "{{ pycamilladsp_plot_tag }}"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 4 additions & 0 deletions release_automation/templates/requirements.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{# Template for pip requirements file -#}
aiohttp
git+https://github.com/HEnquist/pycamilladsp.git@{{ pycamilladsp_tag }}
camilladsp-plot[plot]@git+https://github.com/HEnquist/pycamilladsp-plot.git@{{ pycamilladsp_plot_tag }}
4 changes: 4 additions & 0 deletions release_automation/versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
camillagui_tag: v2.0.0
pycamilladsp_tag: v2.0.2
pycamilladsp_plot_tag: v2.0.0

0 comments on commit a4a4c52

Please sign in to comment.