Skip to content
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
18 changes: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ WORKDIR /code/
COPY pyproject.toml .
COPY uv.lock .

ENV UV_LINK_MODE=copy
RUN uv pip sync --system pyproject.toml
# Set UV_CACHE_DIR to override XDG_CACHE_HOME from the base image
# See https://docs.astral.sh/uv/concepts/cache/#cache-directory
ENV UV_CACHE_DIR="/.cache/uv"

# Using the same path as venv defined in the base image so we can use all the preinstalled packages
ENV UV_PROJECT_ENVIRONMENT="/home/default/"

# The --inexact flag prevents uv from uninstalling the preinstalled packages
RUN uv sync --all-groups --frozen --inexact

# Keboola running containers with "-u 1000:1000" causes permission when installing user defined packages
RUN chown -R 1000:1000 /.cache
RUN chown -R 1000:1000 /code/pyproject.toml
RUN chown -R 1000:1000 /code/uv.lock

COPY src/ src/
COPY tests/ tests/
COPY scripts/ scripts/
COPY flake8.cfg .
COPY deploy.sh .

CMD uv run --active /code/src/component.py
CMD ["uv", "run", "python", "src/component.py"]
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"dlt>=1.6.1",
"duckdb>=1.2.0",
"keboola-component>=1.6.10",
]

Expand Down
4 changes: 2 additions & 2 deletions scripts/build_n_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -e

uv run --active flake8 --config=flake8.cfg
uv run --active python -m unittest discover
uv run flake8 --config=flake8.cfg
uv run python -m unittest discover
7 changes: 3 additions & 4 deletions src/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def execute_script_file(self, file_path):
sys.path.append(self.data_folder_path)

try:
with open(file_path, "r") as file:
with open(file_path) as file:
script = file.read()
logging.info('Executing script "%s"', self.script_excerpt(script))
logging.debug('Executing script "%s"', self.script_excerpt(script))
runpy.run_path(file_path)
logging.info("Script finished")
except Exception as err:
Expand Down Expand Up @@ -95,8 +95,7 @@ def install_packages(packages):
for package in packages:
args = [
"uv",
"pip",
"install",
"add",
package,
]
process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down
Loading