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

Use Hatch for internal dependencies #289

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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 .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.9"

- name: Install local dependencies
run: ./scripts/install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.9"

- name: Install local dependencies
run: ./scripts/install
Expand Down
67 changes: 43 additions & 24 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,82 @@ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
# See https://github.com/mapbox/rasterio/issues/1289
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

RUN python -m pip install --upgrade pip
RUN python -m pip install --upgrade pip uv

# Install azure-cli
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# Install dev dependencies

COPY requirements-dev.txt /opt/src/requirements-dev.txt
RUN cd /opt/src && pip install -r requirements-dev.txt
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src && uv pip install --system -r requirements-dev.txt

#
# Copy and install packages
#

COPY pctasks/core /opt/src/pctasks/core
RUN cd /opt/src/pctasks/core && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/core && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/cli /opt/src/pctasks/cli
RUN cd /opt/src/pctasks/cli && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/cli && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/task /opt/src/pctasks/task
RUN cd /opt/src/pctasks/task && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/task && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/client /opt/src/pctasks/client
RUN cd /opt/src/pctasks/client && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/client && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/ingest /opt/src/pctasks/ingest
RUN cd /opt/src/pctasks/ingest && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/ingest && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/ingest_task /opt/src/pctasks/ingest_task
RUN cd /opt/src/pctasks/ingest_task && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/ingest_task && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/run /opt/src/pctasks/run
RUN cd /opt/src/pctasks/run && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/run && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps -e .

COPY pctasks/server /opt/src/pctasks/server
RUN cd /opt/src/pctasks/server && \
pip install -e .[dev]
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/server && \
uv pip install --system -e .[dev]

COPY pctasks/dataset /opt/src/pctasks/dataset
RUN cd /opt/src/pctasks/dataset && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/dataset && \
uv pip install --system -e .

COPY pctasks/notify /opt/src/pctasks/notify
RUN cd /opt/src/pctasks/notify && \
pip install -e .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/notify && \
uv pip install --system -e .

COPY pctasks/dev /opt/src/pctasks/dev
RUN cd /opt/src/pctasks/dev && \
pip install -e .[server]
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/dev && \
uv pip install --system -e .[server]

# Setup Python Path to allow import of test modules
ENV PYTHONPATH=/opt/src:$PYTHONPATH
Expand Down
39 changes: 26 additions & 13 deletions Dockerfile.task_base
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,48 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Install common packages
COPY requirements-task-base.txt /tmp/requirements.txt
RUN python -m pip install --no-build-isolation -r /tmp/requirements.txt
RUN python -m pip install --no-build-isolation --upgrade pip uv
RUN uv pip install --system -r /tmp/requirements.txt

#
# Copy and install packages
#

COPY pctasks/core /opt/src/pctasks/core
RUN cd /opt/src/pctasks/core && \
pip install .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/core && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

COPY pctasks/cli /opt/src/pctasks/cli
RUN cd /opt/src/pctasks/cli && \
pip install .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/cli && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

COPY pctasks/task /opt/src/pctasks/task
RUN cd /opt/src/pctasks/task && \
pip install .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/task && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

COPY pctasks/client /opt/src/pctasks/client
RUN cd /opt/src/pctasks/client && \
pip install .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/client && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

COPY pctasks/ingest /opt/src/pctasks/ingest
RUN cd /opt/src/pctasks/ingest && \
pip install .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/ingest && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

COPY pctasks/dataset /opt/src/pctasks/dataset
RUN cd /opt/src/pctasks/dataset && \
pip install .
RUN --mount=type=cache,target=/root/.cache \
cd /opt/src/pctasks/dataset && \
uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

# Setup Python Path to allow import of test modules
ENV PYTHONPATH=/opt/src:$PYTHONPATH
Expand Down
7 changes: 4 additions & 3 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# Install python dependencies
COPY deployment/requirements.txt /opt/src/deployment/requirements.txt
RUN pip3 install -r /opt/src/deployment/requirements.txt
RUN pip install uv
RUN uv pip install --system -r /opt/src/deployment/requirements.txt

# Instal pctasks.core
COPY pctasks/core /opt/src/pctasks/core
RUN cd /opt/src/pctasks/core && \
pip install .

uv pip install --system -r requirements.txt && \
uv pip install --system --no-deps .

WORKDIR /opt/deploy
2 changes: 1 addition & 1 deletion deployment/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pypgstac==0.7.3
pypgstac==0.7.10
Jinja2==3.1.2
6 changes: 2 additions & 4 deletions docker-compose.aux.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Non-essential development enviroment servers

version: "2.1"
services:
stac-api:
container_name: pctasks-stac-api
Expand Down Expand Up @@ -57,5 +55,5 @@ services:
networks:
default:
# Network created during scripts/setup
external:
name: pctasks-network
name: pctasks-network
external: true
2 changes: 2 additions & 0 deletions docker-compose.console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ services:
networks:
default:
name: pctasks-network
external: true

5 changes: 2 additions & 3 deletions docker-compose.cosmosdb.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "2.1"
services:
cosmosdb:
container_name: pctasks-cosmosdb
Expand Down Expand Up @@ -34,8 +33,8 @@ services:
networks:
default:
# Network created during scripts/setup
external:
name: pctasks-network
external: true
name: pctasks-network

volumes:
pctasks-cosmosdb-data: null
1 change: 1 addition & 0 deletions docker-compose.tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ services:

networks:
default:
external: true
name: pctasks-network

5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "2.1"
services:
azurite:
container_name: pctasks-azurite
Expand Down Expand Up @@ -206,8 +205,8 @@ services:
networks:
default:
# Network created during scripts/setup
external:
name: pctasks-network
external: true
name: pctasks-network

volumes:
pctasks-azurite-data: null
Expand Down
58 changes: 58 additions & 0 deletions pctasks/cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pctasks.cli"
dynamic = ["version"]
description = "Planetary Computer Tasks framework."
readme = "README.md"
license = "MIT"
requires-python = ">=3.8"
authors = [
{ name = "Microsoft", email = "planetarycomputer@microsoft.com" },
]
keywords = [
"Planetary",
"STAC",
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.8",
]
dependencies = [
"click>=7.0",
"pctasks.core @ {root:parent:uri}/core",
]

[project.optional-dependencies]
dev = [
"pre-commit",
"pytest",
"pytest-cov",
]
docs = [
"mkdocs",
"mkdocs-material",
"pdocs",
]

[project.scripts]
pctasks = "pctasks.cli.cli:cli"

[project.urls]
Homepage = "https://github.com/Microsoft/planetary-computer-tasks"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.version]
path = "pctasks/cli/version.py"

[tool.hatch.build]
include = [
"/pctasks/cli",
]
Loading
Loading