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

Add FEniCS adapter #357

Merged
merged 2 commits into from
Aug 4, 2023
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
30 changes: 19 additions & 11 deletions tools/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ The components mentioned in the Metadata are defined in the central `components.
openfoam-adapter:
repository: https://github.com/precice/openfoam-adapter
template: component-templates/openfoam-adapter.yaml
build-arguments: # these things mean something to the docker-service
build_arguments: # these things mean something to the docker-service
OPENFOAM_EXECUTABLE:
options: ["openfoam2306"]
description: exectuable of OpenFOAM to use
default: "openfoam2306"
options: ["openfoam2112"]
description: exectuable of openfoam to use
default: "openfoam2112"
valentin-seitz marked this conversation as resolved.
Show resolved Hide resolved
PRECICE_TAG:
description: Version of precice to use
default: "latest"
OPENFOAM_ADAPTER_TAG:
description: Ref of the actual OpenFOAM adapter
description: Version of preCICE to use
default: "latest"
OPENFOAM_ADAPTER_REF:
description: Reference/tag of the actual OpenFOAM adapter
default: "master"
```

This `openfoam-adapter` component has the following attributes:
Expand All @@ -97,13 +97,21 @@ This `openfoam-adapter` component has the following attributes:
- `template`: A template for a Docker Compose service of this component
- `build-arguments`: Arguments passed to the Docker Compose service (arbitrary)

#### Naming schema for build_arguments

Since the docker containers are still a bit mixed in terms of capabilities and support for different build_argument combinations the following rules apply:

- A build_argument ending in **_TAG** means that an image of some kind needs to be available with that tag.
- A build_argument ending in **_REF** means that it refers to a git reference (like a branch or commit) beeing used to build the image.
- All other build_arguments are free of rules and up to the container maintainer.

### Component templates

Templates for defining a Docker Compose service for each component are available in `component-templates/`. For example:

```yaml
image: "ghcr.io/precice/openfoam-adapter:{{ params["openfoam-adapter-ref"] }}"
user: ${MY_UID}:${MY_GID}
image: precice/fenics-adapter:{{ params["FENICS_ADAPTER_REF"] }}
user: ${UID}:${GID}
depends_on:
prepare:
condition: service_completed_successfully
Expand All @@ -114,7 +122,7 @@ volumes:
command: >
/bin/bash -c "id &&
cd '/runs/{{ tutorial_folder }}/{{ case_folder }}' &&
{{ params["openfoam-exectuable"] }} {{ run }} | tee {{ case_folder }}.log 2>&1"
{{ run }} | tee {{ case_folder }}.log 2>&1"
```

This template defines:
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/component-templates/fenics-adapter.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: precice/fenics-adapter:{{ params["FENICS_ADAPTER_REF"] }}
image: precice/fenics-adapter:{{ build_arguments["FENICS_ADAPTER_TAG"] }}
user: ${UID}:${GID}
depends_on:
prepare:
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/component-templates/nutils-adapter.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: "ghcr.io/precice/openfoam-adapter:{{ params["openfoam-adapter-ref"] }}" # TODO: Update
image: "ghcr.io/precice/openfoam-adapter:{{ build_arguments["openfoam-adapter-ref"] }}" # TODO: Update
user: ${UID}:${GID}
depends_on:
prepare:
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/component-templates/openfoam-adapter.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build:
context: https://github.com/precice/openfoam-adapter.git#add-ci-docker:tools/docker
args:
{% for key, value in build_args.items() %}
{% for key, value in build_arguments.items() %}
- {{key}}={{value}}
{% endfor %}
user: ${UID}:${GID}
Expand Down
18 changes: 6 additions & 12 deletions tools/tests/components.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openfoam-adapter:
repository: https://github.com/precice/openfoam-adapter
template: component-templates/openfoam-adapter.yaml
build-arguments: # these things mean something to the docker-service
build_arguments: # these things mean something to the docker-service
OPENFOAM_EXECUTABLE:
options: ["openfoam2112"]
description: exectuable of openfoam to use
Expand All @@ -16,21 +16,15 @@ openfoam-adapter:
fenics-adapter:
repository: https://github.com/precice/fenics-adapter
template: component-templates/fenics-adapter.yaml
build-arguments:
PYTHON_BINDINGS_REF:
semnantic: Version of the Python bindings to use
default: "latest"
FENICS_ADAPTER_REF:
semnantic: Version of the fenics adapter to use
default: "latest"
PRECICE_TAG:
description: Version of preCICE to use
build_arguments:
FENICS_ADAPTER_TAG:
semnantic: Version of the fenics adapter image to use
default: "latest"

calculix-adapter:
repository: https://github.com/precice/calculix-adapter
template: component-templates/calculix-adapter.yaml
build-arguments:
build_arguments:
PRECICE_TAG:
description: Version of preCICE to use
default: "latest"
Expand All @@ -40,7 +34,7 @@ calculix-adapter:
nutils-adapter:
repository: https://github.com/precice/nutils-adapter
template: component-templates/nutils-adapter.yaml
build-arguments:
build_arguments:
PRECICE_TAG:
description: Version of preCICE to use
default: "latest"
2 changes: 1 addition & 1 deletion tools/tests/metadata_parser/metdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def from_components_yaml(cls, data):
data: The components YAML data.
"""
arguments = []
for param_name, params in data['build-arguments'].items():
for param_name, params in data['build_arguments'].items():
# TODO maybe **params
description = params.get(
'description', f"No description provided for {param_name}")
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/systemtests/Systemtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def render_service_template_per_case(case: Case, params_to_use: Dict[str, str])
render_dict = {
'run_directory': self.run_directory.resolve(),
'tutorial_folder': self.tutorial_folder,
'build_args': params_to_use,
'build_arguments': params_to_use,
'params': params_to_use,
'case_folder': case.path,
'run': case.run_cmd
Expand Down
Loading