Skip to content

Commit

Permalink
fix: fix python build issues with requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-s committed Jun 24, 2024
1 parent ae6b8ca commit d39e06a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions application/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ runtime:
image: ${RUNTIME_KFP_IMAGE:ghcr.io/scc-digitalhub/digitalhub-core-wrapper-kfp:latest}
python:
images:
PYTHON_3_9: ${RUNTIME_PYTHON_IMAGE_3_9:ghcr.io/scc-digitalhub/digitalhub-serverless/python-runtime-3.9:latest}
PYTHON_3_10: ${RUNTIME_PYTHON_IMAGE_3_10:ghcr.io/scc-digitalhub/digitalhub-serverless/python-runtime-3.10:latest}
PYTHON3_9: ${RUNTIME_PYTHON_IMAGE_3_9:ghcr.io/scc-digitalhub/digitalhub-serverless/python-runtime-3.9:latest}
PYTHON3_10: ${RUNTIME_PYTHON_IMAGE_3_10:ghcr.io/scc-digitalhub/digitalhub-serverless/python-runtime-3.10:latest}
command: /usr/local/bin/processor


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package it.smartcommunitylabdhub.runtime.python.model;

public enum PythonVersion {
PYTHON_3_9("3.9"),
PYTHON_3_10("3.10");
PYTHON3_9("3.9"),
PYTHON3_10("3.10");

private final String version;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ public K8sKanikoRunnable produce(Run run) {
}
}

// install all requirements
dockerfileGenerator.run(
"python /opt/nuclio/whl/$(basename /opt/nuclio/whl/pip-*.whl)/pip install pip --no-index --find-links /opt/nuclio/whl " +
"&& python -m pip install -r /opt/nuclio/requirements/common.txt" +
"&& python -m pip install -r /opt/nuclio/requirements/" +
functionSpec.getPythonVersion().name().toLowerCase() +
".txt"
);

// Add user instructions
Optional
.ofNullable(taskSpec.getInstructions())
.ifPresent(instructions -> instructions.forEach(i -> dockerfileGenerator.run(i)));

// If requirements.txt are defined add to build
if (functionSpec.getRequirements() != null && !functionSpec.getRequirements().isEmpty()) {
//write file
Expand All @@ -158,17 +172,9 @@ public K8sKanikoRunnable produce(Run run) {
.build()
);
// install all requirements
dockerfileGenerator.run(
"python /opt/nuclio/whl/$(basename /opt/nuclio/whl/pip-*.whl)/pip install pip --no-index --find-links /opt/nuclio/whl " +
"&& python -m pip install -r /shared/requirements.txt"
);
dockerfileGenerator.run("python -m pip install -r /shared/requirements.txt");
}

// Add user instructions
Optional
.ofNullable(taskSpec.getInstructions())
.ifPresent(instructions -> instructions.forEach(i -> dockerfileGenerator.run(i)));

// Set entry point
dockerfileGenerator.entrypoint(List.of(command));

Expand Down

0 comments on commit d39e06a

Please sign in to comment.