Skip to content

WIP: Fix/integration #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5bde977
Adds pip workaround as in ITISFoundation/osparc-simcore#540
Jan 28, 2019
8b1cdc2
Flipped position of 'development' target in Dockerfile to speed up im…
Jan 29, 2019
9969cc1
Adds fixes for .pipcache workaround so that it does not fail in devmode
Jan 30, 2019
51e9ae1
renamed integration -> _osparc-simcore folder
Jan 30, 2019
1e2fbcc
Fixes typo in README rendering
Jan 30, 2019
429e5c1
Uninstalls in production stage all dev tools
Jan 30, 2019
c014d78
output folder has osparc-simcore-like folder structure
Jan 30, 2019
f9c3002
Minor: alias target in makefile and added pre-gen hook as sample
Jan 30, 2019
c6dd6de
Fixes test failure
Jan 30, 2019
816dff9
to log or not to logger ...?
Feb 1, 2019
ccad4cd
Added health-check command and script for service
Feb 1, 2019
21cbece
Minors in Makefile
Feb 1, 2019
13cc22f
cleaned up template Makefile and added usage in README.md
Feb 1, 2019
58681d4
Fixes setup naming
Feb 1, 2019
4419d99
Adds setup_swagger to display API documentation
Feb 1, 2019
9569a14
Added exceptions pckage
Feb 1, 2019
7fa72bd
Added microbadger badges for images
Feb 11, 2019
ecee135
Added banners for released docker images
Feb 11, 2019
794fa1c
Merge branch 'master' into fix/integration
pcrespov Feb 11, 2019
cf48b6e
Merge branch 'master' into fix/integration
Feb 11, 2019
a2e851b
Merge branch 'fix/integration' of github.com:pcrespov/cookiecutter-si…
Feb 11, 2019
2351d0b
updated healtcheck
Feb 15, 2019
8725397
Upgrading Dockerfile to deal with non-root users (ITISFoundation/ospa…
Feb 15, 2019
d9707cf
Updated entrypoint and boot as well as docker-compose and .dockerignor
Feb 15, 2019
646696f
Updated doc to underline new features
Feb 15, 2019
6fc2606
Adapting travis to run docker tests
Feb 15, 2019
ff4dc78
Added make target to build prod docker
Feb 15, 2019
509b53a
Disabled docker-build
Feb 15, 2019
db89c55
Minor fixes
Feb 15, 2019
870d609
Fixing app console path
Feb 15, 2019
174cb3e
Simplified PR message
Feb 15, 2019
d38f4d1
Fixes on docker configs after creating webserver and storage services
Feb 18, 2019
7644cd2
minor fixes and doc
Feb 18, 2019
cfab80f
Disabled client-sdk
Feb 19, 2019
7b1c450
Moved client-sdk and integration tests to keep folder
Feb 19, 2019
479b84c
Renamed as 'stub'
Feb 19, 2019
d1ef3b6
Cleaned up cookiecutter attributes list
Feb 19, 2019
441680c
Removed all references to docker in the Makefile
Feb 19, 2019
8d62a77
fix exit code
sanderegg Feb 21, 2019
8a12cea
Fixes development mode in windows where docker mounts all volumes as …
pcrespov Feb 25, 2019
14fc5af
literal user name instead of variable
pcrespov Feb 25, 2019
d1ecbe4
Changend environment variables prefix
pcrespov Feb 26, 2019
9a93bb5
Minor linter
pcrespov Feb 26, 2019
3f1b9e3
Fix issue when docker group name already exists
sanderegg Mar 1, 2019
d1ca5d6
REview: disabled all todos and other minor
pcrespov Mar 5, 2019
acded1f
Added test to check for tags in all generated files
pcrespov Mar 5, 2019
42fa8e3
Review: reduced timeout
pcrespov Mar 5, 2019
1d7bbdf
Cleanedup readme
pcrespov Mar 5, 2019
aa78319
Fixes test and minor changes
pcrespov Mar 5, 2019
bfeeb1e
fixes tests
pcrespov Mar 5, 2019
e4e4298
Review: commented out installed packages in Dockerfile
pcrespov Mar 5, 2019
3892944
fixed TODOs
pcrespov Mar 5, 2019
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
18 changes: 12 additions & 6 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
---
name: Feature request
about: Suggest an idea to implement in the simcore plaform
name: <!-- Feature request -->
about: <!-- Suggest an idea to implement in the simcore plaform -->

---

**USER STORY:**

A clear and concise description of how the feature works and looks like from the user's perspective.
<!--A clear and concise description of how the feature works and looks like from the user's perspective.

Ex. I want to be able the stop the running pipeline by pressing a stop button. If the pipeline is stopped, I see a info-level message confirming it in the logger, if it fails the message should be displayed in red (error). Also, all the progress bars in the nodes must be set to 0.
Ex. I want to be able the stop the running pipeline by pressing a stop button. If the pipeline is stopped, I see a info-level message confirming it in the logger, if it fails the message should be displayed in red (error). Also, all the progress bars in the nodes must be set to 0. -->

**DEFINITION OF DONE:**

A clear and concise description of what the feature requires.
<!--A clear and concise description of what the feature requires.

0. Play button turns into stop button when pipeline is running
1. Stop button turns into play button when pipeline is finished
2. Stop button turns into play button when pipeline is successfully stopped
3. Logger displays messages everytime the play/stop button is pressed
4. Progress bars are set to 0 when stopping pipeline
5. Stop button has a Python interface
-->

**EXAMPLE:**

Any file/screenshot/photomontage/video/website is provided for a better understanding of the request
<!-- Any file/screenshot/photomontage/video/website is provided for a better understanding of the request

Recommended tools for screen captures:
- https://getgreenshot.org/ : very complete screen capture with annotation capabilities [windows only]
- https://www.cockos.com/licecap/ : produces lighweight animated screen captures
-->
21 changes: 7 additions & 14 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!-- Thank you for your contribution!

- Add **WIP-** prefix in title if it is still work in progress (i.e. should not be merged but is ready to start reviewing it)
- Use [waffle.io] keywords in title/descriptions to trigger bot actions:
- close, closes, close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved #[issueNumber]
- connect to, connects to, connected to, connect, connects, connected #[issueNumber]
- parent of, parent to, parent #[issueNumber]
- child of, child to, child #[issueNumber]
- blocks, block, required by, needed by, dependency of #[issueNumber]
- blocked by, required, require, needs, need, depends on #[issueNumber]
-->
<!-- **WIP-** prefix in title if still work in progress -->

## What do these changes do?

Expand All @@ -17,17 +7,20 @@

## Related issue number

<!-- Are there any issues opened that will be resolved by merging this change?
<!--
Use [waffle.io] keywords in title/descriptions to trigger bot actions:

- add mentions of the user or team responsible for reviewing proposed changes
- and user/team to .github/CODEOWNERS to automatically assign reviewers
- close, closes, close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved #[issueNumber]
- connect to, connects to, connected to, connect, connects, connected #[issueNumber]
-->


## Checklist

- [ ] I think the code is well written
- [ ] Unit tests for the changes exist
- [ ] Documentation reflects the changes
- [ ] **Runs in the swarm**
- [ ] If you design a new module, add your user to .github/CODEOWNERS

[waffle.io]:https://waffle.io/marketing-assets/documents/waffleio_cheatsheet_v1.pdf?utm_source=blog&utm_medium=cheatsheet-ctabutton&utm_campaign=cheatsheet
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: python
dist: xenial
addons:
apt:
packages:
- "python3"
- python3
- "python3-pip"
- docker-ce
python:
- "3.6"
install:
Expand Down
3 changes: 3 additions & 0 deletions .vscode-template/install-dev-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# uname -s == Darwin
brew install gnu-sed
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,28 @@ To generate a new cookiecutter template layout just type
```
and answer the questions.


## Backed project

Infrastructure:
- [osparc-simcore]-compatible project skeleton for python services
- service-level makefile (type ``make help``)
- [folder]({{cookiecutter.project_slug}}/extra_osparc-simcore) with stub code to integrate service in [osparc-simcore] framework
- Multi-stage [Dockerfile]({{cookiecutter.project_slug}}/Dockerfile) with different boot modes and healt-check
-
- ...

Service Features:
- [aiohttp] server
- [OpenAPI](https://www.openapis.org/) compatible RESTful API
- ...

Then, to work in the backed project, this is the standard wordflow
``` console
$ cd my project
$ make help

# Create and activate virtual envi
# Create and activate virtual environment
$ make venv
$ source .venv/bin/activate

Expand Down Expand Up @@ -52,26 +68,6 @@ clean – cleans projects directory
clean-force – cleans & removes also venv folder
```

#### Features of the backed project
- [aiohttp] server
- [OpenAPI](https://www.openapis.org/) compatible RESTful API
-
- Predefined project skeleton
- ``.vscode-template`` are recommended settings for vscode
- ``{{cookiecutter.project_slug}}/extra`` contains code modules within a tree folder structure equivalent to [osparc-simcore] repo
- makefile
```console
$ make help
simcore_service_dummy_service:0.1.0

venv – Create the virtual environment
install – Install project sources in "development mode"
uninstall – Uninstall project sources
test – Runs unit tests [w/ fail fast]
help – Display all callable targets
clean – Clean the project's directory
```

---

## Acknoledgements
Expand All @@ -81,6 +77,6 @@ This template was built upon ideas/snippets borrowed from already existing great
This project is licensed under the terms of the [MIT License](/LICENSE)


[aiohptt]:https://aiohttp.readthedocs.io/en/stable/
[aiohttp]:https://aiohttp.readthedocs.io/en/stable/
[cookiecutter]:https://cookiecutter.readthedocs.io
[osparc-simcore]:https://github.com/ITISFoundation/osparc-simcore
15 changes: 10 additions & 5 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"full_name": "Your name",
"github_username": "Your github username",

"project_name": "Name of the project",
"project_short_description": "A short description of the project",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}",
"dockercompose_service_name": "{{ cookiecutter.project_slug }}",
"dockercompose_service_api_port": "8080",

"package_name": "simcore_service_{{ cookiecutter.project_slug|replace('-','_') }}",
"distribution_name": "simcore-service-{{ cookiecutter.project_slug }}",
"command_line_interface_bin_name": "{{ cookiecutter.distribution_name }}",
"simcore_install_root": ["../../", "git+https://github.com/ITISFoundation/osparc-simcore.git@master"],
"release_date": "{% now 'local' %}",

"version": "0.1.0",
"openapi_specs_version": "v{{ cookiecutter.version.split('.')[0] }}",
"sdk_package_name": "simcore_{{ cookiecutter.project_slug|replace('-','_') }}_sdk",

"dockercompose_service_name": "{{ cookiecutter.project_slug }}",
"dockercompose_service_api_port": "8080",

"enable_aiohttp_swagger": ["false", "true"],

"year": "{% now 'utc', '%Y' %}",
"_extensions": ["jinja2_time.TimeExtension"]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
# TODO: unify scripts
# FIXME: activate when ITIFoundation/openapi-tools:latest available
exec {{ cookiecutter.simcore_install_root }}../scripts/openapi/openapi_codegen.sh \
-i ../src/{{ cookiecutter.package_name }}/oas3/{{cookiecutter.openapi_specs_version}}/openapi.yaml \
-o . \
Expand Down
9 changes: 9 additions & 0 deletions keep/{# integration #}/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


# TODO: docker-compose -f services/docker-compose.yml up --exit-code-from={{ cookiecutter.project_name }} {{ cookiecutter.project_name }}

# TODO: docker-compose -f services/docker-compose.yml up --detach {{ cookiecutter.project_name }}
# test if responsive ??

# ls home
# ls /devel
70 changes: 64 additions & 6 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#pylint: disable=W0621
# W0621:Redefining name 'here' from outer scope (line 12)
# pylint:disable=wildcard-import
# pylint:disable=unused-import
# pylint:disable=unused-variable
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name

import logging
import os
import sys
import pytest
import shutil
import subprocess
import logging
import sys
from contextlib import contextmanager

from pathlib import Path

import pytest

logger = logging.getLogger(__name__)

@pytest.fixture
Expand Down Expand Up @@ -38,6 +43,8 @@ def inside_dir(dirpath):
os.chdir(old_path)




def test_project_tree(cookies):
result = cookies.bake(extra_context={'project_slug': 'test_project'})
assert result.exit_code == 0
Expand All @@ -51,13 +58,28 @@ def test_project_tree(cookies):
# with inside_dir(str(result.project)):
# assert subprocess.check_call(['flake8']) == 0

# TODO: use pylint via package instead of application entrypoint
def test_run_pylint(cookies, pylintrc):
result = cookies.bake(extra_context={'project_slug': 'pylint_compat', 'package_name': 'package_folder'})
with inside_dir(str(result.project)):
cmd = 'pylint --rcfile {} -v src/package_folder/'.format(pylintrc.absolute()).split()
assert subprocess.check_call(cmd) == 0


def test_no_tags(cookies):
exclude = ['.pylintrc']
result = cookies.bake(extra_context={
'project_slug': 'myproject', 'package_name': 'package_folder'})
for root, dirs, files in os.walk(result.project):
for fname in files:
if fname not in exclude:
fpath = os.path.join(root, fname)
with open(fpath) as fh:
for lineno, line in enumerate(fh):
assert "TODO" not in line, "{}:{}".format(fpath, lineno)
# skips
dirs[:] = [n for n in dirs if not n.startswith('.')]

def test_run_tests(cookies):
result = cookies.bake(extra_context={'project_slug': 'dummy-project'})
working_dir = str(result.project)
Expand All @@ -73,3 +95,39 @@ def test_run_tests(cookies):
logger.info("Running '%s' ...", cmd)
assert subprocess.check_call(cmd.split()) == 0
logger.info("Done '%s' .", cmd)




@pytest.mark.skip("TODO: Under development")
def test_build_docker(cookies, tmpdir):
# TODO: check build target base, build, cache, prod and devel

# bakes cookie within osparc-simcore tree structure
result = cookies.bake(extra_context={'project_slug': 'dummy-project'})
working_dir = str(result.project)

tmpdir.mkdir("packages").join("dummy.py").write("import os")
new_working_dir = tmpdir.mkdir("services") / os.path.basename(working_dir)
shutil.move(working_dir, new_working_dir)

# ----
commands = (
"ls -la .",
"pip install pip-tools",
"make requirements",
"docker build -f Dockerfile -t dummy-project:prod --target production ../../"
)
with inside_dir(new_working_dir):
for cmd in commands:
logger.info("Running '%s' ...", cmd)
assert subprocess.check_call(cmd.split()) == 0
logger.info("Done '%s' .", cmd)


@pytest.mark.skip("TODO: Under development")
def test_run_docker(cookies, tmpdir):
# check state after boot
# check run permissions `simcore-service-storage --help`
# check load config `simcore-service-storage -c `
pass
16 changes: 16 additions & 0 deletions tools/cleanup-settings.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:: cleanup settings
::
:: UNDER development
::
@echo OFF
setlocal

set HERE=%~dp0
set REPODIR=%HERE%..\

set SETTINGSPATH="%REPODIR%\.vscode\settings.json"
type %SETTINGSPATH% | python -m json.tool --sort-keys > %HERE%workspace-settings.json
:: TODO this should update %SETTINGSPATH%

set SETTINGSPATH="%APPDATA%\Code\User\settings.json"
type %SETTINGSPATH% | python -m json.tool --sort-keys > %HERE%user-settings.json
29 changes: 29 additions & 0 deletions tools/user-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"atomKeymap.promptV3Features": true,
"editor.formatOnPaste": true,
"editor.insertSpaces": false,
"editor.multiCursorModifier": "ctrlCmd",
"editor.renderWhitespace": "all",
"editor.tabSize": 2,
"explorer.confirmDelete": false,
"files.exclude": {
"**/*.pyc": true,
"**/.DS_Store": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/CVS": true
},
"git.enabled": true,
"git.path": "%ConEmuDir%\\vendor\\git-for-windows\\cmd\\git.exe",
"latex-workshop.view.pdf.viewer": "tab",
"python.linting.enabled": true,
"python.pythonPath": "C:\\Users\\crespo\\Miniconda3\\envs\\py3\\python.exe",
"python.unitTest.unittestEnabled": true,
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"%ConEmuDir%\\vendor\\init.bat"
],
"workbench.iconTheme": "vscode-icons"
}
10 changes: 0 additions & 10 deletions {{cookiecutter.project_slug}}/.dockerignore

This file was deleted.

Loading