Skip to content

Commit fab84ff

Browse files
authored
Merge branch 'main' into mlm-candidate
2 parents a2c80d6 + d9fc624 commit fab84ff

38 files changed

+2524
-2367
lines changed

.dockerignore

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424
- name: Set up Python
25-
uses: actions/setup-python@v5.2.0
25+
uses: actions/setup-python@v5.3.0
2626
with:
2727
python-version: "3.10"
28-
- name: Install poetry
29-
run: make poetry-install
28+
- name: Install uv
29+
run: make setup
3030
- name: Publish stac-model to PyPI
3131
run: |
32-
poetry build
33-
poetry publish --username __token__ --password ${{ secrets.PYPI_SECRET }}
32+
uv build
33+
uv publish --username __token__ --password ${{ secrets.PYPI_SECRET }}

.github/workflows/stac-model.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v5.2.0
15+
uses: actions/setup-python@v5.3.0
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818

19-
- name: Install poetry
20-
run: make poetry-install
19+
- name: Install uv
20+
run: make setup
2121

2222
- name: Set up cache
23-
uses: actions/cache@v4.0.2
23+
uses: actions/cache@v4.2.0
2424
with:
2525
path: .venv
26-
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
26+
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }}
2727
- name: Install dependencies
2828
run: make install-dev
2929

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- run: |
1313
npm install
14+
npm list
1415
npm test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
requirements*.txt
2+
13
### ArchLinuxPackages ###
24
*.tar
35
*.tar.*

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
default_language_version:
2-
python: python3.10
2+
python: python3
33

44
default_stages: [commit, push]
5-
65
repos:
76
- repo: https://github.com/pre-commit/pre-commit-hooks
87
rev: v4.5.0

CHANGELOG.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,49 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased](https://github.com/stac-extensions/mlm/tree/main)
8+
## [v1.4.0](https://github.com/stac-extensions/mlm/tree/v1.4.0)
99

1010
### Added
11-
- n/a
11+
- Add better descriptions about required and recommended *MLM Asset Roles* and
12+
their implications (fixes
13+
[#54](https://github.com/stac-extensions/mlm/issues/54)).
14+
- Add explicit check of `value_scaling` sub-fields `minimum`, `maximum`, `mean`, `stddev`, etc. for
15+
corresponding `type` values `min-max` and `z-score` that depend on it.
16+
- Allow different `value_scaling` operations per band/channel/dimension as needed by the model.
17+
- Allow a `processing:expression` for a band/channel/dimension-specific `value_scaling` operation,
18+
granting more flexibility in the definition of input preparation in contrast to having it applied
19+
for the entire input (but still possible).
20+
- Add optional `mlm:compile_method` field at the Asset level with options `aot`
21+
for Ahead of Time Compilation, `jit` for Just-In Time Compilation.
1222

1323
### Changed
14-
- n/a
24+
- Explicitly disallow `mlm:name`, `mlm:input`, `mlm:output` and `mlm:hyperparameters` at the Asset level.
25+
These fields describe the model as a whole and should therefore be defined in Item properties.
26+
- Moved `norm_type` to `value_scaling` object to better reflect the expected operation, which could be another
27+
operation than what is typically known as "normalization" or "standardization" techniques in machine learning.
28+
- Moved `statistics` to `value_scaling` object to better reflect their mutual `type` and additional
29+
properties dependencies.
30+
- moved `mlm:artifact_type` field value descriptions that are framework specific to best-practices section.
31+
- expanded suggested `mlm:artifact_type` values to include Tensorflow/Keras.
1532

1633
### Deprecated
1734
- n/a
1835

1936
### Removed
20-
- n/a
37+
- Removed `norm_type` enum values that were ambiguous regarding their expected result.
38+
Instead, a `processing:expression` should be employed to explicitly define the calculation they represent.
39+
- Removed `norm_clip` property. It is now represented under `value_scaling` objects with a
40+
corresponding `type` definition.
41+
- Removed `norm_by_channel` from `mlm:input` objects. If rescaling (previously normalization in the documentation)
42+
is a single value, broadcasting to the relevant bands should be performed implicitly.
43+
Otherwise, the amount of `value_scaling` objects should match the number of bands or channels involved in the input.
2144

2245
### Fixed
23-
- n/a
46+
- Fix missing `mlm:artifact_type` property check for a Model Asset definition
47+
(fixes <https://github.com/stac-extensions/mlm/issues/42>).
48+
The `mlm:artifact_type` is now mutually and exclusively required by the corresponding Asset with `mlm:model` role.
49+
- Fix check of disallowed unknown/undefined `mlm:`-prefixed fields
50+
(fixes [#41](https://github.com/stac-extensions/mlm/issues/41)).
2451

2552
## [v1.3.0](https://github.com/stac-extensions/mlm/tree/v1.3.0)
2653

@@ -118,7 +145,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
118145
[Asset Object](https://github.com/radiantearth/stac-spec/blob/master/collection-spec/collection-spec.md#asset-object)
119146
to refer to model asset and source code.
120147
- use `classification:classes` in Model Output
121-
- add `scene-classification` to the Enum Tasks to allow disambiguation between pixel-wise and patch-based classification
148+
- add `scene-classification` to the Enum Tasks to allow disambiguation between
149+
pixel-wise and patch-based classification
122150

123151
### Changed
124152
- `disk_size` replaced by `file:size` (see [Best Practices - File Extension](best-practices.md#file-extension))

CONTRIBUTING.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22

33
## Project setup
44

5-
1. If you don't have `Poetry` installed run:
5+
1. If you don't have `uv` installed run:
66

77
```bash
8-
make poetry-install
8+
make setup
99
```
1010

11-
> This installs Poetry as a [standalone application][poetry-install]. <br>
12-
> For more details, see also the [Poetry Documentation][poetry-docs]. <br>
13-
> If you prefer, you can simply install it inside your virtual environment.
11+
> This installs `uv` as a [standalone application][uv-install]. <br>
12+
> For more details, see also the [`uv` documentation][uv-docs]. <br>
1413
15-
2. Initialize project dependencies with poetry and install `pre-commit` hooks:
14+
2. Initialize project dependencies with `uv` and install `pre-commit` hooks:
1615

1716
```bash
1817
make install-dev
1918
make pre-commit-install
2019
```
2120

21+
This will install project dependencies into the currently active environment. If you would like to
22+
use uv's default behavior of managing a project-scoped environment, use `uv` commands directly to
23+
install dependencies. `uv sync` will install dependencies and dev dependencies in `.venv` and update the `uv.lock`.
24+
2225
## PR submission
2326

2427
Before submitting your code please do the following steps:
@@ -85,7 +88,7 @@ git push -u origin your-branch
8588
### Building a new version of `stac-model`
8689

8790
- Apply any relevant changes and `CHANGELOG.md` entries in a PR that modifies `stac-model`.
88-
- Bump the version with `poetry version <version>`.
91+
- Bump the version with `bumpversion bump <version>`.
8992
- You can pass the new version explicitly, or a rule such as `major`, `minor`, or `patch`. <br>
9093
For more details, refer to the [Semantic Versions][semver] standard;
9194
- Once CI validation succeeded, merge the corresponding PR branch.
@@ -110,6 +113,6 @@ You can also share how the ML Model extension does or does
110113
not serve your needs with us in the GitHub Discussions or raise
111114
Issues for bugs.
112115

113-
[poetry-install]: https://github.com/python-poetry/install.python-poetry.org
114-
[poetry-docs]: https://python-poetry.org/docs/
116+
[uv-install]: https://docs.astral.sh/uv/getting-started/installation/
117+
[uv-docs]: https://docs.astral.sh/uv/
115118
[semver]: https://semver.org/

Makefile

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,60 @@
11
#* Variables
22
SHELL ?= /usr/bin/env bash
3-
PYTHON ?= python
4-
PYTHONPATH := `pwd`
5-
POETRY ?= poetry
63

7-
#* Poetry
8-
.PHONY: poetry-install
9-
poetry-install:
10-
curl -sSL https://install.python-poetry.org | $(PYTHON) -
11-
12-
.PHONY: poetry-remove
13-
poetry-remove:
14-
curl -sSL https://install.python-poetry.org | $(PYTHON) - --uninstall
15-
16-
.PHONY: poetry-plugins
17-
poetry-plugins:
18-
$(POETRY) self add poetry-plugin-up
19-
20-
.PHONY: poetry-env
21-
poetry-env:
22-
$(POETRY) config virtualenvs.in-project true
4+
# use the directory rather than the python binary to allow auto-discovery, which is more cross-platform compatible
5+
PYTHON_PATH := $(shell which python)
6+
PYTHON_ROOT := $(shell dirname $(dir $(PYTHON_PATH)))
7+
UV_PYTHON_ROOT ?= $(PYTHON_ROOT)
8+
9+
# to actually reuse an existing virtual/conda environment, the 'UV_PROJECT_ENVIRONMENT' variable must be set to it
10+
# use this command:
11+
# UV_PROJECT_ENVIRONMENT=/path/to/env make [target]
12+
# consider exporting this variable in '/path/to/env/etc/conda/activate.d/env.sh' to enable it by default when
13+
# activating a conda environment, and reset it in '/path/to/env/etc/conda/deactivate.d/env.sh'
14+
UV_PROJECT_ENVIRONMENT ?=
15+
# make sure every uv command employs the specified environment path
16+
ifeq (${UV_PROJECT_ENVIRONMENT},)
17+
UV_COMMAND := uv
18+
else
19+
UV_COMMAND := UV_PROJECT_ENVIRONMENT="${UV_PROJECT_ENVIRONMENT}" uv
20+
endif
21+
22+
#* UV
23+
.PHONY: setup
24+
setup:
25+
which uv >/dev/null || (curl -LsSf https://astral.sh/uv/install.sh | sh)
2326

2427
.PHONY: publish
2528
publish:
26-
$(POETRY) publish --build
29+
$(UV_COMMAND) publish --build
2730

2831
#* Installation
2932
.PHONY: install
30-
install: poetry-env
31-
$(POETRY) lock -n && poetry export --without-hashes > requirements-lock.txt
32-
$(POETRY) install -n
33-
-poetry run mypy --install-types --non-interactive ./
33+
install: setup
34+
$(UV_COMMAND) export --format requirements-txt -o requirements.txt --no-dev
35+
$(UV_COMMAND) pip install --python "$(UV_PYTHON_ROOT)" -r requirements.txt
3436

3537
.PHONY: install-dev
36-
install-dev: poetry-env install
37-
$(POETRY) install -n --with dev
38+
install-dev: setup
39+
$(UV_COMMAND) export --format requirements-txt -o requirements-dev.txt
40+
$(UV_COMMAND) pip install --python "$(UV_PYTHON_ROOT)" -r requirements-dev.txt
3841

3942
.PHONY: pre-commit-install
40-
pre-commit-install:
41-
$(POETRY) run pre-commit install
42-
43+
pre-commit-install: setup
44+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" pre-commit install
4345

4446
#* Formatters
4547
.PHONY: codestyle
46-
codestyle:
47-
$(POETRY) run ruff format --config=pyproject.toml stac_model tests
48+
codestyle: setup
49+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" ruff format --config=pyproject.toml stac_model tests
4850

4951
.PHONY: format
5052
format: codestyle
5153

5254
#* Linting
5355
.PHONY: test
54-
test:
55-
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=stac_model tests/
56+
test: setup
57+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" pytest -c pyproject.toml --cov-report=html --cov=stac_model tests/
5658

5759
.PHONY: check
5860
check: check-examples check-markdown check-lint check-mypy check-safety check-citation
@@ -61,37 +63,28 @@ check: check-examples check-markdown check-lint check-mypy check-safety check-ci
6163
check-all: check
6264

6365
.PHONY: mypy
64-
mypy:
65-
$(POETRY) run mypy --config-file pyproject.toml ./
66+
mypy: setup
67+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" mypy --config-file pyproject.toml ./
6668

6769
.PHONY: check-mypy
6870
check-mypy: mypy
6971

70-
# NOTE:
71-
# purposely running with docker rather than python package due to conflicting dependencies
72-
# see https://github.com/citation-file-format/cffconvert/issues/292
73-
.PHONY: check-citation
74-
check-citation:
75-
docker run --rm -v $(PYTHONPATH)/CITATION.cff:/app/CITATION.cff citationcff/cffconvert --validate
76-
7772
.PHONY: check-safety
78-
check-safety:
79-
$(POETRY) check
80-
$(POETRY) run safety check --full-report
81-
$(POETRY) run bandit -ll --recursive stac_model tests
73+
check-safety: setup
74+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" safety check --full-report
75+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" bandit -ll --recursive stac_model tests
8276

8377
.PHONY: lint
84-
lint:
85-
$(POETRY) run ruff --config=pyproject.toml ./
86-
$(POETRY) run pydocstyle --count --config=pyproject.toml ./
87-
$(POETRY) run pydoclint --config=pyproject.toml ./
78+
lint: setup
79+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" ruff check --fix --config=pyproject.toml ./
8880

8981
.PHONY: check-lint
9082
check-lint: lint
83+
$(UV_COMMAND) run --python "$(UV_PYTHON_ROOT)" ruff check --config=pyproject.toml ./
9184

9285
.PHONY: format-lint
93-
format-lint:
94-
$(POETRY) run ruff --config=pyproject.toml --fix ./
86+
format-lint: lint
87+
ruff format --config=pyproject.toml ./
9588

9689
.PHONY: install-npm
9790
install-npm:
@@ -120,8 +113,9 @@ $(addprefix fix-, $(FORMATTERS)): fix-%: format-%
120113
lint-all: lint mypy check-safety check-markdown
121114

122115
.PHONY: update-dev-deps
123-
update-dev-deps:
124-
$(POETRY) up --only=dev-dependencies --latest
116+
update-dev-deps: setup
117+
$(UV_COMMAND) export --only-dev --format requirements-txt -o requirements-only-dev.txt
118+
$(UV_COMMAND) pip install --python "$(UV_PYTHON_ROOT)" -r requirements-only-dev.txt
125119

126120
#* Cleaning
127121
.PHONY: pycache-remove

0 commit comments

Comments
 (0)