forked from open-edge-platform/geti
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.shared-python
More file actions
113 lines (90 loc) · 3.39 KB
/
Makefile.shared-python
File metadata and controls
113 lines (90 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright (C) 2022-2025 Intel Corporation
# LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
CWD = $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
include $(CWD)/Makefile.shared
DOCKER_IMAGE_DESCRIPTION := $(shell grep "description =" pyproject.toml | sed -n 's/^description = "\(.*\)"/\1/p')
.PHONY: tests test-unit-default test-component-default test-integration-default \
static-code-analysis-default ruff mypy style-fix \
pre-venv venv venv-lock
PYTHONPATH_LOCAL := tests:app
# Dev environment
PYTHON_VERSION := python3.10
# Ensure version in GHA workflow matches uv version here
UV_VERSION := 0.7.13
# PIP installation command
PIP_INSTALL_PARAMS := --trusted-host pypi.org \
--trusted-host pypi.python.org \
--trusted-host files.pythonhosted.org \
CLEAN_DIRS := \
.venv .pytest_cache .coverage .ruff_cache .mypy_cache \
$(find . -name .pytest_cache -type d)
pre-venv:
@if ! uv self version | grep ${UV_VERSION}; then \
curl --proto '=https' --tlsv1.2 -LsSf "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-installer.sh" | sh; \
fi
venv: pre-venv
uv lock --check
uv sync --frozen ${PIP_INSTALL_PARAMS}
venv-lock: pre-venv
uv lock
tests: test-unit test-component test-integration
test-unit-default: venv
@if [ -d "./tests/unit" ]; then \
PYTHONPATH=$(PYTHONPATH_LOCAL) \
uv run pytest ./tests/unit -v; \
else \
echo "./tests/unit directory not found - skipping unit tests"; \
fi
test-integration-default: venv
@if [ -d "./tests/integration" ]; then \
PYTHONPATH=$(PYTHONPATH_LOCAL) \
uv run pytest ./tests/integration -v; \
else \
echo "./tests/integration directory not found - skipping integration tests"; \
fi
test-component-default: venv
@if [ -d "./tests/component" ]; then \
PYTHONPATH=$(PYTHONPATH_LOCAL) \
uv run pytest ./tests/component -v; \
else \
echo "./tests/component directory not found - skipping component tests"; \
fi
install_common_libs:
@echo "This service has no common libs defined."
static-code-analysis-default: ruff mypy
ruff: venv
uv run ruff check --config pyproject.toml
uv run ruff format --check --config pyproject.toml
mypy: venv
uv run mypy $(if $(FILES),$(FILES),.) --config-file=pyproject.toml
style-fix: venv
uv run ruff check --config pyproject.toml --fix
uv run ruff format --config pyproject.toml
build-image:
@echo "Preparing common libs for component: ${COMPONENT_NAME}"
make install_common_libs
@echo "Building docker image for component: ${COMPONENT_NAME}"
@docker build \
${DOCKER_EXTRA_ARGS} \
${DOCKER_BUILD_CONTEXT} \
--label "org.opencontainers.image.description=${DOCKER_IMAGE_DESCRIPTION}" \
-t ${IMAGES_REGISTRY}/${COMPONENT_NAME}:${TAG} \
-f ./Dockerfile .
# TODO: Move to interactive_ai/services after https://youtrack.jetbrains.com/issue/PY-79081 is fixed
# Creates a python venv that can be used for development containing all dependencies for the interactive_ai components
developer-venv: pre-venv
@if [ ! -d ".venv" ]; then \
uv venv; \
fi
@. .venv/bin/activate && \
SERVICES="jobs auto_train dataset_ie director model_registration project_ie resource visual_prompt" && \
for service in $$SERVICES; do \
echo "Installing dependencies for $$service"; \
cd interactive_ai/services/$$service && \
uv sync --frozen --inexact --all-extras --active && \
cd -; \
done
##
# Builder container image
##
BUILDER_IMAGE ?= python-builder