diff --git a/.github/workflows/deploy-pre-release.yml b/.github/workflows/deploy-pre-release.yml index 8582a37..b88d0e9 100644 --- a/.github/workflows/deploy-pre-release.yml +++ b/.github/workflows/deploy-pre-release.yml @@ -13,15 +13,15 @@ defaults: env: LANG: en_US.utf-8 LC_ALL: en_US.utf-8 - PYTHON_VERSION: '3.8' - # Will only deploy to pypi if this matches the - # ${{ $github.repository }} variable - DEPLOY_REPOSITORY: "VOLTTRON/volttron-listener" + PYTHON_VERSION: '3.10' + PROJECT_NAME: volttron-listener + RUNS_ON: ubuntu-22.04 jobs: bump_version: - runs-on: ubuntu-20.04 + environment: test_env + runs-on: ubuntu-22.04 steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" @@ -52,12 +52,29 @@ jobs: virtualenvs-in-project: true installer-parallel: true + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2.1.7 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + #---------------------------------------------- # install your root project, if required #---------------------------------------------- - name: Install library run: | - poetry install --no-interaction --without dev + poetry install --no-interaction #---------------------------------------------- # bump version number for patch @@ -68,9 +85,9 @@ jobs: # we need to remove the v from the begining of the tag. if ! $(git tag -l "v*" = ''); then # uses -V which is version sort to keep it monotonically increasing. - current_tag=$(git tag -l "v*" | sort --reverse -V |sed -n 1p) + current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p) else - current_tag=v0.3.0 + current_tag=v0.4.0 fi current_tag=${current_tag#?} @@ -104,7 +121,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Publish pre-release to pypi - if: github.repository == ${{ env.DEPLOY_REPOSITORY }} + if: github.repository == 'eclipse-volttron/volttron-listener' run: | poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} - poetry publish # -r test-pypi + poetry publish diff --git a/README.md b/README.md index ea7101b..7271284 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,78 @@ -![Passing?](https://github.com/VOLTTRON/volttron-utils/actions/workflows/run-tests.yml/badge.svg) +![Passing?](https://github.com/eclipse-volttron/volttron-listener/actions/workflows/run-tests.yml/badge.svg) -VOLTTRON™ is an open source platform for distributed sensing and control. The platform provides services for collecting and storing data from buildings and devices and provides an environment for developing applications which interact with that data. - -This repository contains utility classes and functions used in [volttron-client](https://github.com/VOLTTRON/volttron-client) and [volttron-server](https://github.com/VOLTTRON/volttron-server). +The volttron-listener agent prints all message traffic across a VOLTTRON bus to standard out. ## Requirements -VOLTTRON is transitioning to using poetry as its base development and deployment environment. Please -[install poetry](https://python-poetry.org/docs/#installation) before continuing. + - Python >= 3.8 ## Installation -The volttron-utils package requires python >=3.6.2,<4.0 in order to run properly. The volttron-utils package is available from pypi To install into the current python environment use: +Create and activate a virtual environment. -```bash -user@path$ pip install volttron-utils +```shell +python -m venv env +source env/bin/activate ``` -## Development +Installing volttron-listener requires a running volttron instance. + +```shell +pip install volttron + +# Start platform with output going to volttron.log +volttron -vv -l volttron.log & +``` -To install development tools including pytest run +Install and start the volttron-listener. -```bash -user@path$ poetry install +```shell +vctl install volttron-listener --start ``` -### Configuration +View the status of the installed agent -Its generally preferred to have the python environments created within the project directory. Execute +```shell +vctl status +``` + +## Development + +Developing on this agent requires poetry 1.2.2 or greater be used. One can install it from https://python-poetry.org/docs/#installation. The VOLTTRON team prefers to have the python environments created within the project directory. Execute this command to make that behavior the default. -```bash -user@path$ poetry config virtualenvs.in-project true +```shell +poetry config virtualenvs.in-project true +``` + +Clone the repository. + +```shell +git clone https://github.com/eclipse-volttron/volttron-listener +``` + +Change to the repository directory and use poetry install to setup the environment. + +```shell +cd volttron-listener +poetry install ``` ### Building Wheel To build a wheel from this project execute the following: -```bash -user@path$ poetry build +```shell +poetry build ``` The wheel and source distribution will be located in the ```./dist/``` directory. ### Bumping version number of project -To bump the version number of volttron-utils execute one of the following. +To bump the version number of the project execute one of the following. -```bash +```shell # patch, minor, major, prepatch, preminor, premajor, prerelease # use patch @@ -64,16 +88,7 @@ user@path$ poetry version prepatch Bumping version from 0.2.0 to 0.2.1-alpha.0 ``` -### Deployment to pypi - -A github action has been created to allow for pushing the wheel to pypi. The requirement for it is to create a tag using v*.*.* for the version of the file. This can be done on a release basis or by pushing a local tag to github. To push a local tag to github in the correct format use the following. - -```bash -user@path$ git tag v0.0.1 -user@path$ git push origin v0.0.1 -``` - -# Disclamer Notice +# Disclaimer Notice This material was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the United diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 2c583eb..0000000 --- a/conftest.py +++ /dev/null @@ -1,58 +0,0 @@ -# import sys -# -# if '..' not in sys.path: -# sys.path.insert(0, '..') -# import os -# import shutil -# import sys -# import tempfile -# -# import pytest -# -# # add -# if "volttron" not in sys.path: -# sys.path.insert(0, "volttron") -# -# -# def create_volttron_home(monkeypatch) -> str: -# """ -# Creates a VOLTTRON_HOME temp directory for use within a testing context. -# This function will return a string containing the VOLTTRON_HOME but will not -# set the global variable. -# :return: str: the temp directory -# """ -# volttron_home = tempfile.mkdtemp(prefix="/tmp/volttron_testing") -# -# # This is needed to run tests with volttron's secure mode. Without this -# # default permissions for folders under /tmp directory doesn't not have read or execute for group or others -# os.chmod(volttron_home, 0o755) -# -# # Move volttron_home to be one level below the mkdir so that -# # the volttron.log file is not part of the same folder for -# # observer. -# volttron_home = os.path.join(volttron_home, "volttron_home") -# os.makedirs(volttron_home) -# -# monkeypatch.setenv("VOLTTRON_HOME", volttron_home) -# -# return volttron_home -# -# -# @pytest.fixture(scope="function") -# def create_volttron_home_fun_scope(monkeypatch): -# -# volttron_home = create_volttron_home(monkeypatch) -# -# yield volttron_home -# -# shutil.rmtree(volttron_home, ignore_errors=True) -# -# -# @pytest.fixture(scope="module") -# def create_volttron_home_mod_scope(monkeypatch): -# -# volttron_home = create_volttron_home(monkeypatch) -# -# yield volttron_home -# -# shutil.rmtree(volttron_home, ignore_errors=True) diff --git a/pyproject.toml b/pyproject.toml index 962499f..9139edf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "volttron-listener" -version = "0.4.0" +version = "0.5.0" description = "None" authors = ["Craig Allwardt "] license = "Apache License 2.0" @@ -19,7 +19,7 @@ classifiers = [ ] [tool.poetry.dependencies] python = ">=3.8,<4.0" -volttron = "^10.0.1a28" +volttron = "^10.0.1a33" [tool.poetry.group.dev.dependencies] # formatting, quality, tests @@ -34,7 +34,7 @@ mypy = "^0.942" coverage = "^6.3.2" Sphinx = "^4.5.0" sphinx-rtd-theme = "^1.0.0" -volttron-testing = "^0.3.1a7" +volttron-testing = "^0.3.1a10" [tool.yapfignore] ignore_patterns = [ diff --git a/src/tests/test_integration.py b/src/tests/test_integration.py index 1eb863d..d245c0c 100644 --- a/src/tests/test_integration.py +++ b/src/tests/test_integration.py @@ -28,6 +28,7 @@ import gevent from volttrontesting import PlatformWrapper +from volttron.client.known_identities import CONTROL def test_startup_instance(volttron_instance: PlatformWrapper): @@ -54,7 +55,7 @@ def test_startup_instance(volttron_instance: PlatformWrapper): listening.callback.reset_mock() assert listening.core.identity - agent_identity = listening.vip.rpc.call('control', 'agent_vip_identity', auuid).get(timeout=10) + agent_identity = listening.vip.rpc.call(CONTROL, 'agent_vip_identity', auuid).get(timeout=10) listening.vip.pubsub.subscribe(peer='pubsub', prefix='heartbeat/{}'.format(agent_identity), callback=listening.callback)