Skip to content
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

Updates cookie-cutter to incorporate new metadata fields in the template #113

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"git_username": "Yourusername",
"default_docker_registry": "itisfoundation",
"release_date": "{% now 'utc', '%Y' %}",
"version": "0.1.0",
"version": "0.1.0",
"_extensions": [
"jinja2_time.TimeExtension"
]
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.osparc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SHELL := /bin/bash
REPO_DIR := $(abspath $(CURDIR)/..)

# NOTE that IMAGES variable can change when docker-compose.yml gets rebuilt. Do NOT use := !!!
IMAGES = $(shell ./bin/yq.bash eval '.services.*.image' docker-compose.yml)
IMAGES = $(shell ./bin/yq eval '.services.*.image' docker-compose.yml)

export DOCKER_REGISTRY ?= registry:5000

Expand Down Expand Up @@ -36,7 +36,7 @@ update-version:
compose: update-version ## creates docker-compose.yml
# creating compose specs
cd $(REPO_DIR) \
&& .osparc/bin/ooil.bash compose -f .osparc/docker-compose.yml
&& .osparc/bin/ooil compose -f .osparc/docker-compose.yml


.PHONY: build build-nc
Expand Down
68 changes: 68 additions & 0 deletions {{cookiecutter.project_slug}}/.osparc/bin/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

# Store the current PATH
export _OLD_OSPARC_PATH=$PATH
pcrespov marked this conversation as resolved.
Show resolved Hide resolved


# Get the directory of the currently running script
BIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OSPARC_ENV=$(dirname "${BIN_DIR}")


# Add .osparc/bin to the PATH
export PATH="$BIN_DIR/.osparc/bin:$PATH"


deactivate () {
# Unset the OLD_PATH variable
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_OSPARC_PATH:+_}" ] ; then
PATH="$_OLD_OSPARC_PATH"
export PATH
unset _OLD_OSPARC_PATH
fi

# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null


# Removes (osparc) in prompt
if ! [ -z "${_OLD_OSPARC_PS1+_}" ] ; then
PS1="$_OLD_OSPARC_PS1"
export PS1
unset _OLD_OSPARC_PS1
fi

unset OSPARC_ENV
unset OSPARC_ENV_PROMPT
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi

echo "osparc environment deactivated"
}

# unset irrelevant variables
deactivate nondestructive


# Adds (osparc) in prompt
if [ "xosparc" != x ] ; then
OSPARC_ENV_PROMPT=".osparc"
else
OSPARC_ENV_PROMPT=$(basename "$OSPARC_ENV")
fi
export OSPARC_ENV_PROMPT


if [ -z "${OSPARC_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_OSPARC_PS1="${PS1-}"
PS1="(${OSPARC_ENV_PROMPT}) ${PS1-}"
export PS1
fi

# Inform the user
echo "Environment activated. To deactivate, type 'deactivate'"
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ WORKDIR="$(pwd)"
#
# NOTE: with --interactive --tty the command below will
# produce colors in the outputs. The problem is that
# . ooil.bash >VERSION will insert special color codes
# . ooil >VERSION will insert special color codes
# . in the VERSION file which make it unusable as a variable
# . when cat VERSION !!
#
Expand All @@ -34,7 +34,7 @@ run() {
# MAIN
#
# USAGE
# ./scripts/ooil.bash --help
# ooil --help

run "$@"
# ----------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'

# Define variables
YQ_IMAGE="mikefarah/yq"
Expand Down
1 change: 1 addition & 0 deletions {{cookiecutter.project_slug}}/.osparc/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ key: simcore/services/{%- if cookiecutter.project_type == "computational" -%}com
type: {{ cookiecutter.project_type }}
integration-version: 1.0.0
version: {{ cookiecutter.version }}
version_display: {{ cookiecutter.version }}
description: {{ cookiecutter.project_short_description }}
contact: {{ cookiecutter.contact_email }}
thumbnail: https://github.com/ITISFoundation/osparc-assets/blob/cb43207b6be2f4311c93cd963538d5718b41a023/assets/default-thumbnail-cookiecutter-osparc-service.png?raw=true
Expand Down
12 changes: 6 additions & 6 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ METADATA := .osparc/metadata.yml
.PHONY: VERSION
VERSION: $(METADATA) ## generates VERSION from metadata
# updating $@ from $<
@$(OSPARC_DIR)/bin/ooil.bash get-version --metadata-file $< > $@
@$(OSPARC_DIR)/bin/ooil get-version --metadata-file $< > $@

service.cli/run: $(METADATA) ## generates run from metadata
# Updates adapter script from metadata in $<
@$(OSPARC_DIR)/bin/ooil.bash run-creator --metadata $< --runscript $@
@$(OSPARC_DIR)/bin/ooil run-creator --metadata $< --runscript $@

docker-compose.yml: $(METADATA) ## generates docker-compose
# Injects metadata from $< as labels
@$(OSPARC_DIR)/bin/ooil.bash compose --to-spec-file $@ --metadata $<
@$(OSPARC_DIR)/bin/ooil compose --to-spec-file $@ --metadata $<



Expand Down Expand Up @@ -72,15 +72,15 @@ info-build: ## displays info on the built image
# TESTS-----------------------------------------------------------------
.PHONY: test tests
test tests: ## runs validation tests
@$(OSPARC_DIR)/bin/ooil.bash test .
@$(OSPARC_DIR)/bin/ooil test .



# PUBLISHING -----------------------------------------------------------------

.PHONY: version-service-patch version-service-minor version-service-major
version-service-patch version-service-minor version-service-major: $(METADATA) ## kernel/service versioning as patch
$(OSPARC_DIR)/bin/ooil.bash bump-version --metadata-file $< --upgrade $(subst version-service-,,$@)
$(OSPARC_DIR)/bin/ooil bump-version --metadata-file $< --upgrade $(subst version-service-,,$@)
# syncing metadata upstream
@$(MAKE) VERSION

Expand Down Expand Up @@ -156,7 +156,7 @@ info: ## general info
@echo ' docker buildx : $(shell docker buildx version)'
@echo ' docker-compose : $(shell docker-compose --version)'
# exe: integration tools
@echo ' ooil version : $(shell $(OSPARC_DIR)/bin/ooil.bash --version)'
@echo ' ooil version : $(shell $(OSPARC_DIR)/bin/ooil --version)'



Expand Down
Loading