Skip to content

Commit

Permalink
Set up GitHub Actions & remove QuickStart support
Browse files Browse the repository at this point in the history
  • Loading branch information
durera committed Jun 1, 2024
1 parent 96a7622 commit e06ac30
Show file tree
Hide file tree
Showing 31 changed files with 288 additions and 432 deletions.
3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
primary-config: ["true", "false"]
include:
- python-version: "3.9"
primary-config: "false"
- python-version: "3.10"
primary-config: "false"
- python-version: "3.11"
primary-config: "true"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install .[dev] flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
ONE_JOB_ONLY_TESTS: ${{secrets[matrix.primary-config]}}
run: |
pytest
# If needed we can gate this step to only run on master
# BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
# if [[ "$BRANCH" == 'refs/heads/master' ]]; then
# pytest
# else
# echo "Tests are only ran for pushes to master"
# fi
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ samples/deviceFactory/bin
samples/*.exe
samples/rbac-config.yaml
test/.DS_Store
/venv
pandoc-*-amd64.deb
README.rst
Binary file removed .tox.ini.swp
Binary file not shown.
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: docs install test build clean

venv:
python3 -m venv venv

clean:
rm -rf venv

install: venv
. venv/bin/activate && python -m pip install --editable .[dev]

test: venv
. venv/bin/activate && pytest

build: venv
rm README.rst
. venv/bin/activate && python -m build

docs:
cd docs && make html
46 changes: 19 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,59 @@
# Python for IBM Watson IoT Platform
Python for IBM Watson IoT Platform
===============================================================================

[![Build Status](https://travis-ci.org/ibm-watson-iot/iot-python.svg?branch=master)](https://travis-ci.org/ibm-watson-iot/iot-python)
[![Coverage Status](https://coveralls.io/repos/github/ibm-watson-iot/iot-python/badge.svg?branch=master)](https://coveralls.io/github/ibm-watson-iot/iot-python?branch=master)
[![GitHub issues](https://img.shields.io/github/issues/ibm-watson-iot/iot-python.svg)](https://github.com/ibm-watson-iot/iot-python/issues)
[![GitHub](https://img.shields.io/github/license/ibm-watson-iot/iot-python.svg)](https://github.com/ibm-watson-iot/iot-python/blob/master/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/wiotp-sdk.svg)](https://pypi.org/project/wiotp-sdk/)
![Project Status](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue)
[![Downloads](https://pepy.tech/badge/ibmiotf)](https://pepy.tech/project/ibmiotf)
[![Downloads](https://pepy.tech/badge/wiotp-sdk)](https://pepy.tech/project/wiotp-sdk)
[![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

Python module for interacting with the [IBM Watson IoT Platform](https://internetofthings.ibmcloud.com).
Python module for interacting with **Maximo IoT** and **[IBM Watson IoT Platform](https://internetofthings.ibmcloud.com)**

- [Python 3.8](https://www.python.org/downloads/release/python-382/) (recommended)
- Python 3.7
- Python 3.6
- Python 3.11
- Python 3.10
- Python 3.9

Note: As of version 0.12, versions of Python less than 3.6 are not officially supported. Compatability with older versions of Python is not guaranteed.

## Product Withdrawal Notice
Product Withdrawal Notice
-------------------------------------------------------------------------------
Per the September 8, 2020 [announcement](https://www-01.ibm.com/common/ssi/cgi-bin/ssialias?subtype=ca&infotype=an&appname=iSource&supplier=897&letternum=ENUS920-136#rprodnx) IBM Watson IoT Platform (5900-A0N) has been withdrawn from marketing effective **December 9, 2020**. As a result, updates to this project will be limited.


## Dependencies

Dependencies
-------------------------------------------------------------------------------
- [paho-mqtt](https://pypi.python.org/pypi/paho-mqtt)
- [iso8601](https://pypi.python.org/pypi/iso8601)
- [pytz](https://pypi.python.org/pypi/pytz)
- [requests](https://pypi.python.org/pypi/requests)


## Installation

Installation
-------------------------------------------------------------------------------
Install the [latest version](https://pypi.org/project/wiotp-sdk/) of the library with pip

```
# pip install wiotp-sdk
```


## Uninstall

Uninstall
-------------------------------------------------------------------------------
Uninstalling the module is simple.

```
# pip uninstall wiotp-sdk
```

## Legacy ibmiotf Module

Version `0.4.0` of the old [ibmiotf](https://pypi.python.org/pypi/ibmiotf) pre-release is still available, if you do not wish to upgrade to the new version, we have no plans to remove this from pypi at this time, however it will not be getting any updates.


## Documentation

Documentation
-------------------------------------------------------------------------------
https://ibm-watson-iot.github.io/iot-python/


## Supported Features

Supported Features
-------------------------------------------------------------------------------
- **Device Connectivity**: Connect your device(s) to Watson IoT Platform with ease using this library
- **Gateway Connectivity**: Connect your gateway(s) to Watson IoT Platform with ease using this library
- **Application connectivity**: Connect your application(s) to Watson IoT Platform with ease using this library
Expand All @@ -69,7 +65,3 @@ https://ibm-watson-iot.github.io/iot-python/
- **Scalable Applications**: Supports load balancing of MQTT subscriptions over multiple application instances.
- **Auto Reconnect**: All clients support automatic reconnect to the Platform in the event of a network interruption.
- **Websockets**: Support device/gateway/application connectivity to Watson IoT Platform using WebSocket


## Unsupported Features
- **Client side Certificate based authentication**: [Client side Certificate based authentication](https://console.ng.bluemix.net/docs/services/IoT/reference/security/RM_security.html)n
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools",
"pypandoc"
]
build-backend = "setuptools.build_meta"
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath="src" "test"
39 changes: 13 additions & 26 deletions samples/psutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,23 @@ A tutorial guiding you through the process of setting up this sample on a Raspbe

## Before you Begin

Register a device with IBM Watson IoT Platform.
Register a device with IBM Watson IoT Platform.

For information on how to register devices, see the [Connecting Devices](https://www.ibm.com/support/knowledgecenter/SSQP8H/iot/platform/iotplatform_task.html) topic in the IBM Watson IoT Platform documentation.
For information on how to register devices, see the [Connecting Devices](https://www.ibm.com/support/knowledgecenter/SSQP8H/iot/platform/iotplatform_task.html) topic in the IBM Watson IoT Platform documentation.

At the end of the registration process, make a note of the following parameters:
At the end of the registration process, make a note of the following parameters:
- Organization ID
- Type ID
- Device ID
- Authentication Token
- Authentication Token

## Docker

The easiest way to test out the sample is via the [wiotp/psutil](https://cloud.docker.com/u/wiotp/repository/docker/wiotp/psutil) Docker image provided and the `--quickstart` command line option.
The easiest way to test out the sample is via the [wiotp/psutil](https://cloud.docker.com/u/wiotp/repository/docker/wiotp/psutil) Docker image provided.

The resource requirements for this container are tiny, if you use the accompanying helm chart it is by default confiugured with a request of 2m CPU + 18Mi memory, and limits set to 4m cpu + 24Mi memory.
The resource requirements for this container are tiny, if you use the accompanying helm chart it is by default configured with a request of 2m CPU + 18Mi memory, and limits set to 4m cpu + 24Mi memory.

```
$ docker run -d --name psutil wiotp/psutil --quickstart
psutil
$ docker logs -tf psutil
2019-05-07T11:09:19.672513500Z 2019-05-07 11:09:19,671 wiotp.sdk.device.client.DeviceClient INFO Connected successfully: d:quickstart:sample-iotpsutil:242ac110002
```

To connect as a registered device in your organization you must set the following environment variables in the container's environment. These variables correspond to the device parameters for your registered device:
To connect as a registered device in your organization you must set the following environment variables in the container's environment. These variables correspond to the device parameters for your registered device:
- `WIOTP_IDENTITY_ORGID`
- `WIOTP_IDENTITY_TYPEID`
- `WIOTP_IDENTITY_DEVICEID`
Expand Down Expand Up @@ -77,13 +70,6 @@ $ helm repo add wiotp https://ibm-watson-iot.github.io/helm/charts/
$ helm install psutil-mydevice wiotp/psutil --values path/to/mydevice.yaml
```

If you provide no additional values the chart will deploy in a configuration supporting Quickstart by default:

```
$ helm repo add wiotp https://ibm-watson-iot.github.io/helm/charts/
$ helm install psutil-quickstart wiotp/psutil
```

The pod consumes very little resource during operation, you can easily max out the default 110 pod/node limit with a cheap 2cpu/4gb worker if you are looking to deploy this chart at scale.


Expand All @@ -104,19 +90,20 @@ pi@raspberrypi ~ $ sudo pip install wiotp-sdk psutil
pi@raspberrypi ~ $ wget https://github.com/ibm-watson-iot/iot-python/archive/master.zip
pi@raspberrypi ~ $ unzip master.zip
pi@raspberrypi ~ $ cd iot-python-master/samples/psutil/src
pi@raspberrypi ~ $ python iotpsutil.py --quickstart
pi@raspberrypi ~ $ export WIOTP_IDENTITY_ORGID=myorgid
pi@raspberrypi ~ $ export WIOTP_IDENTITY_TYPEID=mytypeid
pi@raspberrypi ~ $ export WIOTP_IDENTITY_DEVICEID=mydeviceid
pi@raspberrypi ~ $ export WIOTP_AUTH_TOKEN=myauthtoken
pi@raspberrypi ~ $ python iotpsutil.py
(Press Ctrl+C to disconnect)
```

Note: Set the same environment variables detailed in the Docker section of this README (above) and ommit the `--quickstart` argument to connect your Raspberry Pi to IBM Watson IoT Platform as a registered device.


## Support Application
A sample application is provided that allows commands to be sent to the device when used in registered mode only.

The application provides two functions:
* Adjust the publish rate of the psutil device sample
* Adjust the publish rate of the psutil device sample
* Print a debug message to the console on the device

```
Expand Down
5 changes: 0 additions & 5 deletions samples/psutil/helm/psutil/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{ if eq .Values.identity.orgId "quickstart" }}
args:
- "--quickstart"
{{ else }}
env:
- name: WIOTP_IDENTITY_ORGID
value: {{ .Values.identity.orgId }}
Expand All @@ -37,7 +33,6 @@ spec:
# Note: this can contain special characters, so we wrap the value in quotes
- name: WIOTP_AUTH_TOKEN
value: "{{ .Values.auth.token }}"
{{ end }}
resources:
{{ toYaml .Values.resources | indent 12 }}

3 changes: 1 addition & 2 deletions samples/psutil/helm/psutil/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ resources:


# WIoTP device configuration properties -- override these to connect
# Without any configuration, the defaults will result in a connection to Quickstart
identity:
orgId: quickstart
orgId: <undefined>
typeId: <undefined>
deviceId: <undefined>
auth:
Expand Down
Loading

0 comments on commit e06ac30

Please sign in to comment.