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
56 changes: 56 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI Pipeline SmartOcean Virtual Node - development branch

on:
push:
branches: [ "development" ]
pull_request:
branches: [ "development" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install Poetry
run: |
python -m pip install --user pipx
python -m pipx ensurepath
pipx install poetry
poetry config virtualenvs.in-project true

- name: Cache dependencies
uses: actions/cache@v4
id: cache
with:
path: ./.venv
key: venv-${{ hashFiles('**/poetry.lock')}}

- name: Install Poetry dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
# poetry lock
poetry install --no-root

- name: Lint with flake8
run: |
source .venv/bin/activate
# 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: Run tests
run: |
source .venv/bin/activate
export PYTHONPATH=$(pwd)/src
# pytest -sv
36 changes: 36 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# DataSpace Service Client SDK

## Local installation with pip

If you want to work on this module to test, debug, or develop, this module can be
installed locally on your system as source code. The path to the folder ``src`` needs to be in
your `PYTHONPATH`. Then the module can be accessed from client code using:

```python
import sfisop.dataspace_sdk
```

In addition, install the dependencies needed for this module in your ``python`` environment using the
``requirements.txt`` in the root folder:


```bash
python3 -m pip install -r requirements.txt
```

Setup `PYTHONPATH` to include the ``src`` folder:

```
export PYTHONPATH=<path to top-level folder>/dataspace_sdk/src/
```

# Installation with poetry

You can install this module on your system locally using ``poetry`` (https://python-poetry.org/). You might want to do
this if you have made some local changes to the code and want to install them in your environment.
To do this install ``poetry`` and execute the following commands:

```bash
poetry build
pip install dist/ sfisop_dataspace_sdk-<version>-py3-none-any.whl
```
56 changes: 23 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,60 @@ Basic client library for accessing the SmartOcean data space service to retrieve

The SmartOcean dataspace service provides a REST API. The Swagger documentation is available via: https://dataspaceservice.jollywater-00619340.westus2.azurecontainerapps.io/docs

# Installation
# Installing as a module

The module is part of a collection of client modules for the SFI Smart Ocean platform under the sfisop namespace on ``pypi.org``.

## Installing as a module

To use the distributed module on pypi install this and other modules you may require for your Smart Ocean client
using pip:

```bash
pip install sfisop-dataspace-sdk
```

## Local installation
If you want to work on this module to test, debug, or develop, this module can be
installed locally on your system as source code. The path to the folder ``src`` needs to be in
your PYTHONPATH. Then the module can be accessed from client code using:
# Sample Client Code

```python
import sfisop.dataspace_sdk
```
A sample implementation of the client-side code is provided in the `main.py` file.

In addition, install the dependencies needed for this module in your ``python`` environment using the
``requirements.txt`` in the root folder:
```python
import datetime

from sfisop.dataspace_sdk.client import DataSpaceClient
from sfisop.dataspace_sdk.config import get_dataspace_config, get_dataspace_configfile
from sfisop.dataspace_sdk import sop_datasources as data_sources

```bash
python3 -m pip install -r requirements.txt
```
if __name__ == '__main__':

Setup `PYTHONPATH` to include the ``src`` folder:
config_file = get_dataspace_configfile("DataSpace Configuration")
dataspace_config = get_dataspace_config(config_file)

```
export PYTHONPATH=<path to top-level folder>/dataspace_sdk/src/
```
client = DataSpaceClient(dataspace_config)

# Installation with poetry
response_latest = client.get_latest(data_sources.HVLVIRTUAL)
print(response_latest.status_code)
print(response_latest.text)

You can install this module on your system locally using ``poetry`` (https://python-poetry.org/). You might want to do
this if you have made some local changes to the code and want to install them in your environment.
To do this install ``poetry`` and execute the following commands:
start_time = datetime.datetime(2024, 6, 1, 0, 0, 0)
end_time = datetime.datetime(2024, 6, 7, 0, 0, 0)

```bash
poetry build
pip install dist/ sfisop_dataspace_sdk-<version>-py3-none-any.whl
response_period = client.get_period(data_sources.HVLVIRTUAL, start_time, end_time)
print(response_period.status_code)
print(response_period.text)
```

## Sample Client Code

A sample implementation of the client-side code is provided in the `sample_client.py` file.

It can be executed as:

```bash
python sample_client.py <path-to-configuration-file>
python client.py <path-to-configuration-file>
```

The code is to be used as a starting point for the implementation of the client applications.

A configuration file that can be used for the SmartOcean data space service can be found in the configs folder.

The data sources are currently available on the SmartOcean platform for demonstration purposes can be found in the `sample_datasources.py` file.
The data sources are currently available on the SmartOcean platform for demonstration purposes can be found in the `sop_datasources.py` file.

## Configuration and credentials
# Configuration and credentials

The configuration file provided as on the command-line must contain the following information:

Expand Down
Loading
Loading