Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
name: Ruff linting, formating, MyPy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.8"
cache: true
- name: Install dependencies
run: |
pdm venv create --with-pip --force $PYTHON
pdm sync --dev -G:all
- run: |
pdm run ruff format --check
pdm run ruff check
pdm run lint-mypy

# Run unit tests only on Windows/MacOS, we can run the full test suite on Linux
test-unit:
name: Windows/MacOS unit tests
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os:
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
- name: Install dependencies
run: |
pdm venv create --with-pip --force $PYTHON
pdm sync --dev -G:all
- run: pdm run test-unit

# we can only run our full test suite on Ubuntu due to the Github Actions services requirement
test-complete:
name: Test with coverage
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
services:
rabbitmq:
image: "bitnami/rabbitmq:3.13.3"
env:
# space-delimited list of plugins
RABBITMQ_PLUGINS: "rabbitmq_mqtt"
RABBITMQ_USERNAME: "intersect_username"
RABBITMQ_PASSWORD: "intersect_password"
# misleading env name, this is needed to set "loopback_users.$USERNAME = false"
RABBITMQ_MANAGEMENT_ALLOW_WEB_ACCESS: "yes"
ports:
- "1883:1883" # MQTT port
- "5672:5672" # AMQP port
minio:
image: "bitnami/minio:2024.6.4"
env:
MINIO_ROOT_USER: AKIAIOSFODNN7EXAMPLE
MINIO_ROOT_PASSWORD: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
MINIO_SKIP_CLIENT: "yes"
ports:
- "9000:9000" # main MINIO API port
- "9001:9001" # web UI
steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
- name: Install dependencies
run: |
pdm venv create --with-pip --force $PYTHON
pdm sync --dev -G:all
- run: pdm run test-all
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# container for CI/CD or development - NOT meant to be an extensible Docker image with the installed package

ARG REPO=code.ornl.gov:4567/rse/images/
ARG REPO=

# use this stage for development
FROM ${REPO}python:3.8-slim as minimal
Expand Down
30 changes: 11 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
# Simple docker-compose file which sets up all needed backing services
# Note that for the broker, the default credentials are ` intersect_username / intersect_password `

version: "3"

x-broker-variables: &broker-variables
BROKER_HOST: broker
BROKER_PORT: 1883
BROKER_USERNAME: intersect_username
BROKER_PASSWORD: intersect_password

x-minio-variables: &minio-variables
MINIO_HOST: minio
MINIO_PORT: 9000
MINIO_ACCESS_KEY: AKIAIOSFODNN7EXAMPLE
MINIO_SECRET_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

services:
broker:
image: code.ornl.gov:4567/intersect/sdk/broker/main:latest
image: "bitnami/rabbitmq:3.13.3"
ports:
- "1883:1883" # MQTT port
- "5672:5672" # AMQP port
- "15672:15672" # Web UI
environment:
# full list of env variables available at https://github.com/bitnami/containers/blob/main/bitnami/rabbitmq/README.md
RABBITMQ_PLUGINS: "rabbitmq_mqtt"
RABBITMQ_USERNAME: "intersect_username"
RABBITMQ_PASSWORD: "intersect_password"
RABBITMQ_MANAGEMENT_ALLOW_WEB_ACCESS: "yes"
healthcheck:
test: rabbitmq-diagnostics -q ping
test: rabbitmq-diagnostics -q ping && rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms
interval: 10s
retries: 5
start_period: 10s
timeout: 10s

minio:
image: quay.io/minio/minio
image: "bitnami/minio:2024.6.4"
environment:
# references: https://github.com/bitnami/containers/blob/main/bitnami/minio/README.md
MINIO_ROOT_USER: AKIAIOSFODNN7EXAMPLE
MINIO_ROOT_PASSWORD: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
ports:
- "9000:9000" # main MINIO API port
- "9001:9001" # web UI
#volumes:
#- "./tmp/minio:/mydata"
command: 'server /mydata --console-address ":9001"'
#- "./tmp/minio:/bitnami/minio/data"
25 changes: 11 additions & 14 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation and usage
======================

Install Python via `Anaconda <https://www.anaconda.com>`_ or `Conda <https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html>`_. Anaconda installs Python along with many other graphical tools and scientific packages. Conda is an open-source packaging, dependency, and environment management tool which also installs Python. Notice that Miniconda is a smaller version of Anaconda that includes only Conda and a few dependencies.
You will need to use a Python version >= 3.8.10 . You can install Python via `Anaconda <https://www.anaconda.com>`_ or `Conda <https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html>`_. Anaconda installs Python along with many other graphical tools and scientific packages. Conda is an open-source packaging, dependency, and environment management tool which also installs Python. Notice that Miniconda is a smaller version of Anaconda that includes only Conda and a few dependencies.

After installing Python, make a folder for your project, then create a virtual environment in that folder and activate the environment as follows:

Expand All @@ -15,12 +15,12 @@ After installing Python, make a folder for your project, then create a virtual e
python -m venv venv
source venv/bin/activate

Next, install the intersect-sdk package into the virtual environment using the command shown below. The ``<token>`` must be replaced with your GitLab token. For example, if your token is ``12345`` then replace ``<token>`` in the URL with ``12345`` then run the command. See the **Authenticating** section below for information on how to generate a token.
Next, install the intersect-sdk package into the virtual environment using the command shown below.

.. code-block:: bash

# Install the intersect-sdk package into the virtual environment
pip install -i https://user:<token>@code.ornl.gov/api/v4/groups/5609/-/packages/pypi/simple intersect-sdk
pip install intersect-sdk

You should now be able to import the package in a Python script, notebook, or program using:

Expand All @@ -37,12 +37,10 @@ Use the command shown below to deactivate the virtual environment:

If you would like to run the examples, such as the :doc:`examples/hello-world` example, you may need to install Docker and run a broker service. See the sections below for more information.

Authenticating
--------------
Installation using a prebuilt Docker image
------------------------------------------

Some INTERSECT dependencies are stored on private package registries on code.ornl.gov; therefore, a personal access token is required for installation. Create a personal access token on the `Access Tokens page <https://code.ornl.gov/-/profile/personal_access_tokens>`_ in GitLab Preferences with ``read_api`` or ``api`` permissions then save the auto-generated key. This key is only displayed immediately after generating it, so be sure to save it (otherwise a new token will need to be generated).

For the Docker containers, you need to login to the GitLab Container registry using the command shown below. Then sign in with your UCAMS or XCAMS credentials.
If you want to utilize the prebuilt INTERSECT-SDK Docker container, you need to login to the GitLab Container registry using the command shown below. Then sign in with your UCAMS or XCAMS credentials.

.. code-block:: bash

Expand All @@ -51,26 +49,25 @@ For the Docker containers, you need to login to the GitLab Container registry us
Docker
------

`Docker <https://www.docker.com>`_ is used to create containers for using the Python SDK and to run the examples. Download and install Docker using the instructions provided on their website. See the **Authenticating** section below to use the GitLab Container registry which contains INTERSECT dependencies.
`Docker <https://www.docker.com>`_ is used to create containers for using the Python SDK and to run the examples. Download and install Docker using the instructions provided on their website.

Backing Services (Brokers, Data planes)
---------------------------------------

A Docker Compose configuration for SDK development is included below. Note that the broker configuration requires access to the INTERSECT Gitlab, and is available at https://code.ornl.gov/intersect/sdk/broker.
A Docker Compose configuration for SDK development is included below.

Note that this broker image, and any data plane images, are meant for testing and should not be included in production.
Note that this configuration is meant for testing, and should not be included in production.

.. literalinclude:: ../docker-compose.yml

From the repository root, run the backing services using the Docker commands shown below. See the previous section regarding authentication for the login command.
From the repository root, run the backing services using the Docker commands shown below.

.. code-block:: bash

docker login code.ornl.gov:4567
# if you are copypasting from this website instead of running from the repository root, you should make sure you copy the contents into docker-compose.yml.
docker compose up -d

To see the broker's management UI, you can navigate to ``localhost:15672`` in your browser. The login credentials will be those found in the broker's `definitions file <https://code.ornl.gov/intersect/sdk/broker/-/blob/0.2.0/definitions.json>`_.
To see the broker's management UI, you can navigate to ``localhost:15672`` in your browser. The login credentials mirror `RABBITMQ_USERNAME` and `RABBITMQ_PASSWORD` from the docker-compose file.

To cleanup:

Expand Down
Loading