-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Garcia Ordonez
committed
Aug 28, 2024
0 parents
commit 24de9ae
Showing
15 changed files
with
546 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This file exists so you can easily regenerate your project. | ||
# | ||
# `cookiepatcher` is a convenient shim around `cookiecutter` | ||
# for regenerating projects (it will generate a .cookiecutterrc | ||
# automatically for any template). To use it: | ||
# | ||
# pip install cookiepatcher | ||
# cookiepatcher gh:itisfoundation/cookiecutter-osparc-service project-path | ||
# | ||
# See: | ||
# https://pypi.python.org/pypi/cookiepatcher | ||
# | ||
# Alternatively, you can run: | ||
# | ||
# cookiecutter --overwrite-if-exists --config-file=project-path/.cookiecutterrc gh:itisfoundation/cookiecutter-osparc-service | ||
# | ||
|
||
default_context: | ||
|
||
_checkout: None | ||
_output_dir: '/home/ordonez/osparc_projects/cookiecutter-osparc-service' | ||
_repo_dir: '.' | ||
_template: '.' | ||
author_affiliation: 'sdfas' | ||
author_email: '[email protected]' | ||
author_name: 'asdf' | ||
contact_email: '[email protected]' | ||
default_docker_registry: 'itisfoundation' | ||
docker_base: 'ubuntu:18.04' | ||
git_repo: 'local' | ||
git_username: 'Yourusername' | ||
number_of_inputs: '1' | ||
number_of_outputs: '1' | ||
project_name: 'dummy' | ||
project_package_name: 'dummy' | ||
project_short_description: 'dummy' | ||
project_slug: 'dummy' | ||
project_type: 'computational' | ||
release_date: '2024' | ||
version: '0.1.0' | ||
version_display: '0.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## Common.dockerignore | ||
|
||
* | ||
!src/ | ||
!service.cli/ | ||
!docker/ | ||
!.osparc/ | ||
|
||
# Common | ||
README.md | ||
CHANGELOG.md | ||
docker-compose.yml | ||
Dockerfile | ||
|
||
# git | ||
.git | ||
.gitattributes | ||
.gitignore | ||
.git* | ||
|
||
## Common.gitignore | ||
|
||
# output folders | ||
build/ | ||
output/ | ||
out/ | ||
|
||
# temporary folders | ||
tmp/ | ||
|
||
# explicit mark | ||
*ignore* | ||
.tmp* | ||
|
||
# vscode configuration | ||
.vscode | ||
|
||
# make outputs | ||
pytest_*.xml | ||
.compose* | ||
|
||
# validation folder | ||
!validation/**/* | ||
# docker ignore | ||
!.dockerignore | ||
# git ignore | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Common.gitignore | ||
|
||
# output folders | ||
build/ | ||
output/ | ||
out/ | ||
|
||
# temporary folders | ||
tmp/ | ||
|
||
# explicit mark | ||
*ignore* | ||
.tmp* | ||
|
||
# vscode configuration | ||
.vscode | ||
|
||
# make outputs | ||
pytest_*.xml | ||
.compose* | ||
|
||
# validation folder | ||
!validation/**/* | ||
# docker ignore | ||
!.dockerignore | ||
# git ignore | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: "3.7" | ||
services: | ||
dummy: | ||
build: | ||
dockerfile: docker/ubuntu/Dockerfile | ||
target: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: dummy | ||
key: simcore/services/comp/dummy | ||
type: computational | ||
integration-version: 2.0.0 | ||
version: 0.1.0 | ||
description: dummy | ||
contact: [email protected] | ||
thumbnail: https://github.com/ITISFoundation/osparc-assets/blob/cb43207b6be2f4311c93cd963538d5718b41a023/assets/default-thumbnail-cookiecutter-osparc-service.png?raw=true | ||
authors: | ||
- name: asdf | ||
email: [email protected] | ||
affiliation: sdfas | ||
inputs: | ||
input_1: | ||
displayOrder: 1 | ||
label: input_1_label | ||
description: The input 1 description | ||
type: string | ||
defaultValue: some_value(optional) | ||
fileToKeyMap: | ||
somefilename.ext: input_1 | ||
|
||
outputs: | ||
output_1: | ||
displayOrder: 1 | ||
label: output_1_label | ||
description: The input 1 description | ||
type: string | ||
fileToKeyMap: | ||
somefilename.ext: output_1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
restart-policy: no-restart | ||
settings: | ||
- name: Resources | ||
type: Resources | ||
value: | ||
Limits: | ||
NanoCPUs: 1000000000 # 100% of CPU cycles on 1 CPU | ||
MemoryBytes: 2147483648 # 2 Gigabytes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# | ||
# Author: asdf | ||
|
||
SHELL = /bin/sh | ||
.DEFAULT_GOAL := help | ||
|
||
export VCS_URL := $(shell git config --get remote.origin.url 2> /dev/null || echo unversioned repo) | ||
export VCS_REF := $(shell git rev-parse --short HEAD 2> /dev/null || echo unversioned repo) | ||
export VCS_STATUS := $(if $(shell git status -s 2> /dev/null || echo unversioned repo),'modified/untracked','clean') | ||
export BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
|
||
export DOCKER_IMAGE_NAME ?= dummy | ||
export DOCKER_IMAGE_TAG ?= 0.1.0 | ||
|
||
OSPARC_DIR:=$(CURDIR)/.osparc | ||
|
||
APP_NAME := dummy | ||
|
||
# Builds new service version ---------------------------------------------------------------------------- | ||
|
||
define _bumpversion | ||
# upgrades as $(subst $(1),,$@) version, commits and tags | ||
@docker run -it --rm -v $(PWD):/${DOCKER_IMAGE_NAME} \ | ||
-u $(shell id -u):$(shell id -g) \ | ||
itisfoundation/ci-service-integration-library:v1.0.4 \ | ||
sh -c "cd /${DOCKER_IMAGE_NAME} && bump2version --verbose --list --config-file $(1) $(subst $(2),,$@)" | ||
endef | ||
|
||
.PHONY: version-patch version-minor version-major | ||
version-patch version-minor version-major: .bumpversion.cfg ## increases service's version | ||
@make compose-spec | ||
@$(call _bumpversion,$<,version-) | ||
@make compose-spec | ||
|
||
.PHONY: compose-spec | ||
compose-spec: ## runs ooil to assemble the docker-compose.yml file | ||
@docker run --rm -v $(PWD):/${DOCKER_IMAGE_NAME} \ | ||
-u $(shell id -u):$(shell id -g) \ | ||
itisfoundation/ci-service-integration-library:v1.0.4 \ | ||
sh -c "cd /${DOCKER_IMAGE_NAME} && ooil compose" | ||
|
||
build: | compose-spec ## build docker image | ||
docker compose build | ||
|
||
# To test built service locally ------------------------------------------------------------------------- | ||
.PHONY: run-local | ||
run-local: ## runs image with local configuration | ||
docker compose --file docker-compose-local.yml up | ||
|
||
.PHONY: publish-local | ||
publish-local: ## push to local oSPARC to test integration. It requires the oSPARC platform running on your computer, you can find more information here: https://github.com/ITISFoundation/osparc-simcore/blob/master/README.md | ||
docker tag simcore/services/dynamic/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} registry:5000/simcore/services/dynamic/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) | ||
docker push registry:5000/simcore/services/dynamic/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) | ||
@curl registry:5000/v2/_catalog | jq | ||
|
||
.PHONY: help | ||
help: ## this colorful help | ||
@echo "Recipes for '$(notdir $(CURDIR))':" | ||
@echo "" | ||
@awk 'BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
@echo "" | ||
|
||
|
||
# COOKIECUTTER ----------------------------------------------------------------- | ||
|
||
.PHONY: replay | ||
replay: .cookiecutterrc ## re-applies cookiecutter | ||
# Replaying . ... | ||
@cookiecutter --no-input --overwrite-if-exists \ | ||
--config-file=$< \ | ||
--output-dir="$(abspath $(CURDIR)/..)" \ | ||
"." | ||
|
||
|
||
.PHONY: info | ||
info: ## general info | ||
# env vars: version control | ||
@echo " VCS_URL : $(VCS_URL)" | ||
@echo " VCS_REF : $(VCS_REF)" | ||
@echo " VCS_STATUS : $(VCS_STATUS)" | ||
# env vars: docker | ||
@echo " DOCKER_IMAGE_TAG : $(DOCKER_IMAGE_TAG)" | ||
@echo " BUILD_DATE : $(BUILD_DATE)" | ||
# exe: recommended dev tools | ||
@echo ' git : $(shell git --version 2>/dev/null || echo not found)' | ||
@echo ' make : $(shell make --version 2>&1 | head -n 1)' | ||
@echo ' jq : $(shell jq --version 2>/dev/null || echo not found z)' | ||
@echo ' awk : $(shell awk -W version 2>&1 | head -n 1 2>/dev/null || echo not found)' | ||
@echo ' python : $(shell python3 --version 2>/dev/null || echo not found )' | ||
@echo ' docker : $(shell docker --version)' | ||
@echo ' docker buildx : $(shell docker buildx version)' | ||
@echo ' docker compose : $(shell docker compose --version)' | ||
|
||
# MISC ----------------------------------------------------------------- | ||
|
||
|
||
.PHONY: clean | ||
git_clean_args = -dxf --exclude=.vscode/ | ||
|
||
clean: ## cleans all unversioned files in project and temp files create by this makefile | ||
# Cleaning unversioned | ||
@git clean -n $(git_clean_args) | ||
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ] | ||
@echo -n "$(shell whoami), are you REALLY sure? [y/N] " && read ans && [ $${ans:-N} = y ] | ||
@git clean $(git_clean_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# dummy | ||
|
||
dummy | ||
|
||
## Usage | ||
|
||
```console | ||
$ make help | ||
|
||
$ make build | ||
$ make info-build | ||
$ make tests | ||
``` | ||
|
||
## Workflow | ||
|
||
1. The source code shall be copied to the [src](dummy/src/dummy) folder. | ||
2. The [Dockerfile](dummy/src/Dockerfile) shall be modified to compile the source code. | ||
3. The [.osparc](.osparc) is the configuration folder and source of truth for metadata: describes service info and expected inputs/outputs of the service. | ||
4. The [execute](dummy/service.cli/execute) shell script shall be modified to run the service using the expected inputs and retrieve the expected outputs. | ||
5. The test input/output shall be copied to [validation](dummy/validation). | ||
6. The service docker image may be built and tested as ``make build tests`` (see usage above) | ||
7. Optional: if your code requires specific CPU/RAM resources, edit [runtime.yml](.osparc/runtime.yml). In doubt, leave it as default. | ||
|
||
## Have an issue or question? | ||
Please open an issue [in this repository](https://github.com/ITISFoundation/cookiecutter-osparc-service/issues/). | ||
--- | ||
<p align="center"> | ||
<image src="https://github.com/ITISFoundation/osparc-simcore-python-client/blob/4e8b18494f3191d55f6692a6a605818aeeb83f95/docs/_media/mwl.png" alt="Made with love at www.z43.swiss" width="20%" /> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: '3.7' | ||
services: | ||
dummy: | ||
build: | ||
context: ./ | ||
dockerfile: docker/ubuntu/Dockerfile | ||
labels: | ||
io.simcore.name: '{"name": "dummy"}' | ||
io.simcore.thumbnail: '{"thumbnail": "https://github.com/ITISFoundation/osparc-assets/blob/cb43207b6be2f4311c93cd963538d5718b41a023/assets/default-thumbnail-cookiecutter-osparc-service.png?raw=true"}' | ||
io.simcore.description: '{"description": "dummy"}' | ||
io.simcore.key: '{"key": "simcore/services/comp/dummy"}' | ||
io.simcore.version: '{"version": "0.1.0"}' | ||
io.simcore.integration-version: '{"integration-version": "2.0.0"}' | ||
io.simcore.type: '{"type": "computational"}' | ||
io.simcore.authors: '{"authors": [{"name": "asdf", "email": "[email protected]", | ||
"affiliation": "sdfas"}]}' | ||
io.simcore.contact: '{"contact": "[email protected]"}' | ||
io.simcore.inputs: '{"inputs": {"input_1": {"displayOrder": 1.0, "label": | ||
"input_1_label", "description": "The input 1 description", "type": "string", | ||
"fileToKeyMap": {"somefilename.ext": "input_1"}, "defaultValue": "some_value(optional)"}}}' | ||
io.simcore.outputs: '{"outputs": {"output_1": {"displayOrder": 1.0, "label": | ||
"output_1_label", "description": "The input 1 description", "type": "string", | ||
"fileToKeyMap": {"somefilename.ext": "output_1"}}}}' | ||
org.label-schema.build-date: '2024-08-28T16:31:41Z' | ||
org.label-schema.schema-version: '1.0' | ||
org.label-schema.vcs-ref: '' | ||
org.label-schema.vcs-url: '' | ||
simcore.service.restart-policy: no-restart | ||
simcore.service.settings: '[{"name": "Resources", "type": "Resources", "value": | ||
{"Limits": {"NanoCPUs": 1000000000, "MemoryBytes": 2147483648}}}]' | ||
target: production | ||
image: simcore/services/comp/dummy:0.1.0 |
Oops, something went wrong.