Skip to content

Commit ec40d25

Browse files
authored
Merge pull request #127 from 3DBAG/uv-setup
Uv setup
2 parents dee41da + b4cc164 commit ec40d25

30 files changed

+5964
-207
lines changed

.github/hooks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
version=$(bumpver show --no-fetch | cut -d' ' -f3)
4+
if ! grep -q "\[${version}\]" CHANGELOG.md; then
5+
echo "Error: CHANGELOG.md has not been updated for version ${version}"
6+
exit 1
7+
fi

.github/scripts/parse_changelog.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import re
2+
import sys
3+
from typing import Optional
4+
5+
6+
def parse_changelog(version: str) -> Optional[str]:
7+
"""Parse CHANGELOG.md and return the content for the specified version.
8+
9+
Args:
10+
version: Version string to find in the changelog (e.g. "2024.12.16")
11+
12+
Returns:
13+
String containing the changelog entry for the specified version,
14+
or None if version not found
15+
"""
16+
with open("CHANGELOG.md", "r") as f:
17+
content = f.read()
18+
19+
# Pattern to match version headers
20+
version_header_pattern = r"## \[([\d.]+)\]"
21+
22+
# Find all version headers and their positions
23+
version_matches = list(re.finditer(version_header_pattern, content))
24+
25+
# Find the index of our target version
26+
target_index = None
27+
for i, match in enumerate(version_matches):
28+
if match.group(1) == version:
29+
target_index = i
30+
break
31+
32+
if target_index is None:
33+
print(f"No changelog entry found for version {version}")
34+
return None
35+
36+
# Get the start position (right after the version header)
37+
start_pos = version_matches[target_index].end()
38+
39+
# Get the end position (start of next version or end of file)
40+
if target_index + 1 < len(version_matches):
41+
end_pos = version_matches[target_index + 1].start()
42+
else:
43+
end_pos = len(content)
44+
45+
# Extract the content between these positions
46+
changelog_content = content[start_pos:end_pos]
47+
48+
# Clean up the content
49+
# Remove leading/trailing whitespace and empty lines while preserving internal formatting
50+
cleaned_lines = []
51+
for line in changelog_content.split('\n'):
52+
if line.strip() or cleaned_lines: # Keep empty lines only after we've started collecting content
53+
cleaned_lines.append(line)
54+
55+
# Remove trailing empty lines
56+
while cleaned_lines and not cleaned_lines[-1].strip():
57+
cleaned_lines.pop()
58+
59+
return '\n'.join(cleaned_lines)
60+
61+
62+
if __name__ == "__main__":
63+
if len(sys.argv) != 2:
64+
print("Usage: python parse_changelog.py VERSION")
65+
sys.exit(1)
66+
67+
version = sys.argv[1]
68+
changelog_content = parse_changelog(version)
69+
70+
if changelog_content:
71+
with open("RELEASE_NOTES.md", "w") as f:
72+
f.write(changelog_content)
73+
print("Successfully extracted changelog content")
74+
else:
75+
print("Failed to extract changelog content")
76+
sys.exit(1)

.github/workflows/documentation.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
path: .cache
2626
restore-keys: |
2727
mkdocs-material-
28-
- run: |
29-
pip install -r requirements-dev.txt
30-
pip install --no-deps packages/common
31-
- run: mkdocs gh-deploy --force
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v4
30+
- name: Run mkdocs
31+
run: uv run mkdocs gh-deploy --force

.github/workflows/lint-and-formatting.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ jobs:
1818
python-version: "3.11"
1919
- name: Install uv
2020
uses: astral-sh/setup-uv@v5
21-
- name: Install dependencies
22-
run: uv pip install ruff --system
2321
- name: Lint
24-
run: ruff check
22+
run: uv tool run ruff check
2523
- name: Format
26-
run: ruff format --check
24+
run: uv tool run ruff format --check

.github/workflows/release.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
description: Create a new release for the 3dbag-pipeline with the specified version, use the release notes from the CHANGELOG.md file and create a pull request to merge the changes back to the develop branch.
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
on:
9+
workflow_dispatch:
10+
branches:
11+
- master
12+
inputs:
13+
version:
14+
description: '3dbag-pipeline release version (YYYY.MM.DD)'
15+
required: true
16+
type: string
17+
18+
jobs:
19+
release:
20+
if: github.ref == 'refs/heads/master'
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.12'
31+
32+
- name: Install bumpver
33+
run: pip install bumpver
34+
35+
- name: Configure Git
36+
run: |
37+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
38+
git config --local user.name "github-actions[bot]"
39+
40+
- name: Update version
41+
run: |
42+
bumpver update --set-version=${{ github.event.inputs.version }} --no-fetch
43+
44+
- name: Parse Changelog
45+
run: |
46+
python .github/scripts/parse_changelog.py ${{ github.event.inputs.version }}
47+
48+
- name: Create GitHub Release
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
tag_name: v${{ github.event.inputs.version }}
52+
name: 3DBAG ${{ github.event.inputs.version }}
53+
body_path: RELEASE_NOTES.md
54+
draft: false
55+
prerelease: false
56+
57+
- name: Create Pull Request to develop
58+
uses: peter-evans/create-pull-request@v7
59+
with:
60+
branch: merge-release-back-to-develop
61+
base: develop
62+
title: 'Merge release ${{ github.event.inputs.version }} back to develop'
63+
body: |
64+
This PR merges the changes from release ${{ github.event.inputs.version }} back to the develop branch.
65+
66+
Changes included in this release:
67+
68+
```
69+
$(cat RELEASE_NOTES.md)
70+
```
71+
labels: |
72+
release
73+
automated pr
74+
delete-branch: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ docs/reference
3434
# Tools
3535
.tox
3636
.coverage
37-
*.ruff_cache
37+
*.ruff_cache
38+
*.python-version

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
All notable changes to the 3dbag-pipeline are documented in this file.
3+
For the changes in the 3DBAG data set, see the [3DBAG release notes](https://docs.3dbag.nl/en/overview/release_notes/).
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6+
7+
## [2024.12.16]
8+
9+
Release that produced the 3DBAG data set version 2024.12.16.
10+
11+
### Added
12+
- Documentation for deploying the 3dbag-pipeline, contributor guidelines and the project layout.
13+
- Docker-based deployment.
14+
- CI pipeline for testing and docker image builds.
15+
16+
### Changed
17+
- Major refactoring of the project structure for easier maintenance and deployment.
18+
19+
### Docker images
20+
21+
The docker images for this release:
22+
- `3dgi/3dbag-pipeline-dagster:2024.12.16`
23+
- `3dgi/3dbag-pipeline-core:2024.12.16`
24+
- `3dgi/3dbag-pipeline-floors-estimation:2024.12.16`
25+
- `3dgi/3dbag-pipeline-party-walls:2024.12.16`

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ You can read about the details on how can you deploy it in the [deployment secti
4343

4444
## Production
4545

46+
## Integration as a library
47+
48+
The 3dbag-pipeline can be used as a library in other projects.
49+
The packages can be installed directly from GitHub using specific release versions:
50+
51+
```bash
52+
# Install specific release version of the common package
53+
pip install "bag3d-common @ git+https://github.com/3DBAG/[email protected]#egg=bag3d-common&subdirectory=packages/common"
54+
55+
# Install specific commit of the common package
56+
pip install "bag3d-common @ git+https://github.com/3DBAG/3dbag-pipeline.git@<commit-hash>#egg=bag3d-common&subdirectory=packages/common"
57+
```
58+
4659
## License
4760

4861
Licensed under either of

docker/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ services:
8989
# dagster's DockerRunLauncher, it always starts a new container from the image, for
9090
# each run. While, watch:action:sync (or sync+restart)copies the changed local code into the
9191
# 3dbag-pipeline-core-develop container (not the image). But since DockerRunLauncher
92-
# doesn't actaully use this container, but always starts a new one, we have to build
92+
# doesn't actually use this container, but always starts a new one, we have to build
9393
# a new image on each change.
9494
develop:
9595
watch:

docker/pipeline/bag3d-core.dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,28 @@ LABEL org.opencontainers.image.licenses="(MIT OR Apache-2.0)"
1212
WORKDIR $BAG3D_PIPELINE_LOCATION
1313

1414
ENV UV_PROJECT_ENVIRONMENT=$VIRTUAL_ENV
15-
# Install dependencies
15+
16+
# Install only dependencies except the bag3d-common package
1617
RUN --mount=type=cache,target=/root/.cache/uv \
18+
--mount=type=bind,source=./packages/core/uv.lock,target=$BAG3D_PIPELINE_LOCATION/packages/core/uv.lock \
1719
--mount=type=bind,source=./packages/core/pyproject.toml,target=$BAG3D_PIPELINE_LOCATION/packages/core/pyproject.toml \
1820
uv sync \
21+
--frozen \
22+
--all-extras \
1923
--no-install-project \
24+
--no-install-package bag3d-common\
2025
--project $BAG3D_PIPELINE_LOCATION/packages/core \
2126
--python $VIRTUAL_ENV/bin/python
2227

2328
COPY . $BAG3D_PIPELINE_LOCATION
2429

25-
# Install the workflow package
30+
# Install the workflow package and the bag3d-common package in editable mode
2631
RUN --mount=type=cache,target=/root/.cache/uv \
27-
uv pip install -e $BAG3D_PIPELINE_LOCATION/packages/core/.[dev] && \
28-
uv pip install -e $BAG3D_PIPELINE_LOCATION/packages/common/.[dev]
32+
uv sync \
33+
--frozen \
34+
--all-extras \
35+
--project $BAG3D_PIPELINE_LOCATION/packages/core \
36+
--python $VIRTUAL_ENV/bin/python
2937

3038
# Run dagster gRPC server on port 4000
3139
EXPOSE 4000

0 commit comments

Comments
 (0)