Skip to content

Commit 28fe956

Browse files
authored
director OpenAPI, refactoring (#187)
migrated to AIOHTTP uses openapi to define its REST API API cleaned up server code is partly auto-generated from the API sdk python client code is auto-generated from the API scripts to re-generate code available webserver adapted incorporate #148
1 parent ff965c1 commit 28fe956

File tree

168 files changed

+18205
-2310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+18205
-2310
lines changed

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "eslint:recommended",
33
"parser": "babel-eslint",
44
"globals": {
5-
"osparc": false
5+
"osparc": false,
6+
"window": false
67
},
78
"rules": {
89
"max-len": [

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ services/docker-compose.swarm.yml
122122
# key-words in filename to ignore them
123123
*secret*
124124
*ignore*
125+
126+
# Any output directory
127+
*output/
128+
# backup files
129+
*~
130+
*.bak

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ matrix:
3838
- pip install --upgrade pip wheel setuptools && pip3 --version
3939
- pip3 install packages/s3wrapper[test]
4040
- pip3 install packages/simcore-sdk[test]
41+
- pip3 install services/director[test]
42+
- pip3 install packages/director-sdk/python
4143
- pushd services/web/server; pip3 install -r requirements/ci.txt; popd
4244

4345
before_script:

Makefile

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# author: Sylvain Anderegg
22

33
# TODO: add flavours by combinging docker-compose files. Namely development, test and production.
4-
VERSION := $(shell cat /proc/version)
4+
VERSION := $(shell uname -a)
55
# SAN this is a hack so that docker-compose works in the linux virtual environment under Windows
66
ifneq (,$(findstring Microsoft,$(VERSION)))
77
export DOCKER_COMPOSE=docker-compose
88
export DOCKER=docker
99
export RUN_DOCKER_ENGINE_ROOT=1
10+
# Windows does not have these things defined... but they are needed to execute a local swarm
11+
export DOCKER_GID=1001
12+
export HOST_GID=1000
1013
else
1114
export DOCKER_COMPOSE=docker-compose
1215
export DOCKER=docker
1316
export RUN_DOCKER_ENGINE_ROOT=0
17+
# TODO: Add a meaningfull call to retrieve the local docker group ID and the user ID in linux.
1418
endif
1519

16-
PY_FILES = $(strip $(shell find services packages -iname '*.py' -not -path "*egg*" -not -path "*contrib*"))
20+
PY_FILES = $(strip $(shell find services packages -iname '*.py' -not -path "*egg*" -not -path "*contrib*" -not -path "*/director-sdk/python*" -not -path "*/generated_code/models*" -not -path "*/generated_code/util*"))
21+
1722
export PYTHONPATH=${CURDIR}/packages/s3wrapper/src:${CURDIR}/packages/simcore-sdk/src
1823

1924
all:
@@ -31,7 +36,7 @@ rebuild-devel:
3136
${DOCKER_COMPOSE} -f services/docker-compose.yml -f services/docker-compose.devel.yml build --no-cache
3237

3338
up-devel:
34-
${DOCKER_COMPOSE} -f services/docker-compose.yml -f services/docker-compose.devel.yml up
39+
${DOCKER_COMPOSE} -f services/docker-compose.yml -f services/docker-compose.devel.yml -f services/docker-compose.tools.yml up
3540

3641
build:
3742
${DOCKER_COMPOSE} -f services/docker-compose.yml build
@@ -40,18 +45,18 @@ rebuild:
4045
${DOCKER_COMPOSE} -f services/docker-compose.yml build --no-cache
4146

4247
up:
43-
${DOCKER_COMPOSE} -f services/docker-compose.yml up
48+
${DOCKER_COMPOSE} -f services/docker-compose.yml -f services/docker-compose.tools.yml up
4449

4550
up-swarm:
4651
${DOCKER} swarm init
47-
${DOCKER} stack deploy -c services/docker-compose.yml -c services/docker-compose.deploy.yml services
52+
${DOCKER} stack deploy -c services/docker-compose.yml -c services/docker-compose.deploy.yml -c services/docker-compose.tools.yml services
4853

4954
up-swarm-devel:
5055
${DOCKER} swarm init
51-
${DOCKER} stack deploy -c services/docker-compose.yml -c services/docker-compose.devel.yml -c services/docker-compose.deploy.devel.yml services
56+
${DOCKER} stack deploy -c services/docker-compose.yml -c services/docker-compose.devel.yml -c services/docker-compose.deploy.devel.yml -c services/docker-compose.tools.yml services
5257

5358
down:
54-
${DOCKER_COMPOSE} -f services/docker-compose.yml down
59+
${DOCKER_COMPOSE} -f services/docker-compose.yml -f services/docker-compose.tools.yml down
5560
${DOCKER_COMPOSE} -f services/docker-compose.yml -f services/docker-compose.devel.yml down
5661

5762
down-swarm:
@@ -84,6 +89,7 @@ run_test:
8489
pytest --cov=s3wrapper -v packages/s3wrapper/tests
8590
pytest --cov=simcore_sdk -v packages/simcore-sdk/tests
8691
pytest --cov=server -v services/web/server/tests
92+
pytest --cov=simcore_service_director -v services/director/tests
8793

8894
after_test:
8995
# leave a clean slate (not sure whether this is actually needed)

packages/director-sdk/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# simcore-director-sdk
2+
3+
The simcore-director-sdk is the client library needed to access the director REST Api.
4+
5+
It is currently available as an auto-generated python package but could be easily generated for other languages.
6+
7+
## Usage
8+
9+
pip install -v git+https://github.com/ITISFoundation/osparc-simcore.git@director-sdk#subdirectory=packages/director-sdk/python
10+
11+
## Development
12+
13+
No development as the code is automatically generated.
14+
15+
### local testing
16+
17+
Do the following:
18+
1. Start the oSparc swarm
19+
```bash
20+
make build
21+
make up-swarm
22+
```
23+
2. Execute __sample.py__ as an example
24+
3. Observe logs
25+
26+
## code generation from REST API "client side"
27+
28+
Python: The code was generated using the __codegen.sh__ script together with __codegen_config.json__.

packages/director-sdk/codegen.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#/bin/bash
2+
exec ../../scripts/openapi/openapi_codegen.sh \
3+
-i ../../services/director/src/simcore_service_director/.oas3/v1/openapi.yaml \
4+
-o . \
5+
-g python \
6+
-c ./codegen_config.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"packageName":"simcore_director_sdk",
3+
"projectName":"simcore-director-sdk",
4+
"packageVersion":"1.0.0",
5+
"packageUrl":"https://github.com/ITISFoundation/osparc-simcore/tree/master/packages/director-sdk/python",
6+
"library":"asyncio"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.3.0-SNAPSHOT
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ref: https://docs.travis-ci.com/user/languages/python
2+
language: python
3+
python:
4+
- "2.7"
5+
- "3.2"
6+
- "3.3"
7+
- "3.4"
8+
- "3.5"
9+
#- "3.5-dev" # 3.5 development branch
10+
#- "nightly" # points to the latest development branch e.g. 3.6-dev
11+
# command to install dependencies
12+
install: "pip install -r requirements.txt"
13+
# command to run tests
14+
script: nosetests
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# simcore-director-sdk
2+
This is the oSparc's director API
3+
4+
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
5+
6+
- API version: 1.0.0
7+
- Package version: 1.0.0
8+
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
9+
10+
## Requirements.
11+
12+
Python 2.7 and 3.4+
13+
14+
## Installation & Usage
15+
### pip install
16+
17+
If the python package is hosted on Github, you can install directly from Github
18+
19+
```sh
20+
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
21+
```
22+
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
23+
24+
Then import the package:
25+
```python
26+
import simcore_director_sdk
27+
```
28+
29+
### Setuptools
30+
31+
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
32+
33+
```sh
34+
python setup.py install --user
35+
```
36+
(or `sudo python setup.py install` to install the package for all users)
37+
38+
Then import the package:
39+
```python
40+
import simcore_director_sdk
41+
```
42+
43+
## Getting Started
44+
45+
Please follow the [installation procedure](#installation--usage) and then run the following:
46+
47+
```python
48+
from __future__ import print_function
49+
import time
50+
import simcore_director_sdk
51+
from simcore_director_sdk.rest import ApiException
52+
from pprint import pprint
53+
54+
# create an instance of the API class
55+
api_instance = simcore_director_sdk.UsersApi(simcore_director_sdk.ApiClient(configuration))
56+
57+
try:
58+
# Service health-check endpoint
59+
api_response = api_instance.root_get()
60+
pprint(api_response)
61+
except ApiException as e:
62+
print("Exception when calling UsersApi->root_get: %s\n" % e)
63+
64+
```
65+
66+
## Documentation for API Endpoints
67+
68+
All URIs are relative to *http://{host}:{port}/{version}*
69+
70+
Class | Method | HTTP request | Description
71+
------------ | ------------- | ------------- | -------------
72+
*UsersApi* | [**root_get**](docs/UsersApi.md#root_get) | **GET** / | Service health-check endpoint
73+
*UsersApi* | [**running_interactive_services_delete**](docs/UsersApi.md#running_interactive_services_delete) | **DELETE** /running_interactive_services/{service_uuid} | Stops and removes an interactive service from the oSparc platform
74+
*UsersApi* | [**running_interactive_services_get**](docs/UsersApi.md#running_interactive_services_get) | **GET** /running_interactive_services/{service_uuid} | Succesfully returns if a service with the defined uuid is up and running
75+
*UsersApi* | [**running_interactive_services_post**](docs/UsersApi.md#running_interactive_services_post) | **POST** /running_interactive_services | Starts an interactive service in the oSparc platform and returns its entrypoint
76+
*UsersApi* | [**services_by_key_version_get**](docs/UsersApi.md#services_by_key_version_get) | **GET** /services/{service_key}/{service_version} | Returns details of the selected service if available in the oSparc platform
77+
*UsersApi* | [**services_get**](docs/UsersApi.md#services_get) | **GET** /services | Lists available services in the oSparc platform
78+
79+
80+
## Documentation For Models
81+
82+
- [Error](docs/Error.md)
83+
- [ErrorEnveloped](docs/ErrorEnveloped.md)
84+
- [HealthCheck](docs/HealthCheck.md)
85+
- [HealthCheckEnveloped](docs/HealthCheckEnveloped.md)
86+
- [NodeMetaV0](docs/NodeMetaV0.md)
87+
- [Nodemetav0Authors](docs/Nodemetav0Authors.md)
88+
- [Response204Enveloped](docs/Response204Enveloped.md)
89+
- [RunningService](docs/RunningService.md)
90+
- [RunningServiceEnveloped](docs/RunningServiceEnveloped.md)
91+
- [ServicesEnveloped](docs/ServicesEnveloped.md)
92+
93+
94+
## Documentation For Authorization
95+
96+
All endpoints do not require authorization.
97+
98+
99+
## Author
100+
101+
102+
103+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Error
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**message** | **str** | Error message |
7+
**errors** | **list[object]** | | [optional]
8+
**status** | **int** | Error code |
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ErrorEnveloped
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data** | [**Error**](Error.md) | | [optional]
7+
**status** | **int** | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# HealthCheck
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**name** | **str** | | [optional]
7+
**status** | **str** | | [optional]
8+
**api_version** | **str** | | [optional]
9+
**version** | **str** | | [optional]
10+
11+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
12+
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# HealthCheckEnveloped
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data** | [**HealthCheck**](HealthCheck.md) | | [optional]
7+
**status** | **int** | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# NodeMetaV0
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**key** | **str** | distinctive name for the node based on the docker registry path |
7+
**version** | **str** | semantic version number |
8+
**type** | **str** | service type |
9+
**name** | **str** | short, human readable name for the node |
10+
**description** | **str** | human readable description of the purpose of the node |
11+
**authors** | [**list[Nodemetav0Authors]**](Nodemetav0Authors.md) | |
12+
**contact** | **str** | email to correspond to the authors about the node |
13+
**inputs** | **object** | definition of the inputs of this node |
14+
**outputs** | **object** | definition of the outputs of this node |
15+
16+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
17+
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Nodemetav0Authors
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**name** | **str** | Name of the author | [optional]
7+
**email** | **str** | Email address | [optional]
8+
**affiliation** | **str** | Affiliation of the author | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Response204Enveloped
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data** | **str** | | [optional]
7+
**status** | **int** | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# RunningService
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**published_port** | **int** | The ports where the service provides its interface |
7+
**entry_point** | **str** | The entry point where the service provides its interface if specified | [optional]
8+
**service_uuid** | **str** | The UUID attached to this service |
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RunningServiceEnveloped
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data** | [**RunningService**](RunningService.md) | | [optional]
7+
**status** | **int** | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ServicesEnveloped
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data** | [**list[NodeMetaV0]**](NodeMetaV0.md) | | [optional]
7+
**status** | **int** | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+

0 commit comments

Comments
 (0)