Skip to content

Commit c2dd0e3

Browse files
authored
Merge pull request #107 from kazmer97/feature/python-upgrade
Ugrade python
2 parents e8eee09 + b0884ee commit c2dd0e3

File tree

12 files changed

+462
-13
lines changed

12 files changed

+462
-13
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: MIT-0
3+
4+
name: Developer Tests
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- '**' # Run on PR open, update, or synchronize (i.e., any push to PR branch)
10+
11+
# Global timeout for all jobs
12+
# Note: GitHub Actions uses minutes, GitLab uses duration strings
13+
jobs:
14+
developer_tests:
15+
name: Lint, Type Check, and Test
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 120 # 2 hours
18+
19+
# Use Python 3.13 to match GitLab configuration
20+
container:
21+
image: python:3.13-bookworm
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Fetch all history for git diff in typecheck-pr
28+
29+
- name: Set up Git safe directory
30+
run: |
31+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
32+
33+
- name: Fetch base branch
34+
run: |
35+
git fetch origin ${{ github.base_ref || 'main' }}:refs/remotes/origin/${{ github.base_ref || 'main' }}
36+
git branch -a
37+
38+
- name: Set up environment
39+
run: |
40+
python --version
41+
apt-get update -y
42+
apt-get install make curl -y
43+
44+
- name: Install uv
45+
run: |
46+
curl -LsSf https://astral.sh/uv/install.sh | sh
47+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
48+
49+
- name: Create virtual environment
50+
run: |
51+
uv venv .venv
52+
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
53+
54+
- name: Install Node.js and basedpyright
55+
run: |
56+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
57+
apt-get install -y nodejs
58+
npm install -g basedpyright
59+
60+
- name: Install Python dependencies
61+
run: |
62+
uv pip install ruff
63+
uv pip install typer rich boto3
64+
cd lib/idp_common_pkg && uv pip install -e ".[test]" && cd ../..
65+
66+
- name: Run linting checks
67+
run: make lint-cicd
68+
69+
- name: Run type checking
70+
run: |
71+
TARGET_BRANCH="${{ github.base_ref }}"
72+
echo "=== Type Checking Configuration ==="
73+
echo "PR target branch (github.base_ref): $TARGET_BRANCH"
74+
echo "Comparing: origin/$TARGET_BRANCH...HEAD"
75+
echo "===================================="
76+
echo ""
77+
78+
python3 scripts/typecheck_pr_changes.py "$TARGET_BRANCH"
79+
80+
- name: Run tests
81+
id: run-tests
82+
run: make test-cicd -C lib/idp_common_pkg
83+
continue-on-error: false
84+
85+
- name: Upload coverage reports
86+
uses: actions/upload-artifact@v4
87+
if: always() && steps.run-tests.outcome != 'skipped'
88+
with:
89+
name: test-reports
90+
path: |
91+
lib/idp_common_pkg/test-reports/coverage.xml
92+
lib/idp_common_pkg/test-reports/test-results.xml
93+
retention-days: 7
94+
95+
- name: Publish test results
96+
uses: EnricoMi/publish-unit-test-result-action@v2
97+
if: always() && hashFiles('lib/idp_common_pkg/test-reports/test-results.xml') != ''
98+
with:
99+
files: lib/idp_common_pkg/test-reports/test-results.xml
100+
check_name: Test Results
101+
102+
- name: Code Coverage Report
103+
uses: irongut/CodeCoverageSummary@v1.3.0
104+
if: always() && hashFiles('lib/idp_common_pkg/test-reports/coverage.xml') != ''
105+
with:
106+
filename: lib/idp_common_pkg/test-reports/coverage.xml
107+
badge: true
108+
fail_below_min: false
109+
format: markdown
110+
hide_branch_rate: false
111+
hide_complexity: true
112+
indicators: true
113+
output: both
114+
thresholds: '60 80'
115+
116+
- name: Add Coverage PR Comment
117+
uses: marocchino/sticky-pull-request-comment@v2
118+
if: github.event_name == 'pull_request' && hashFiles('code-coverage-results.md') != ''
119+
with:
120+
recreate: true
121+
path: code-coverage-results.md

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ notebooks/examples/data
2323
.idea/
2424
.dsr/
2525
*tmp-dev-assets*
26-
scratch/
26+
scratch/
27+
28+
# Node.js / npm
29+
node_modules/
30+
package-lock.json
31+
32+
# Type checking
33+
pyrightconfig.temp.json
34+
.pyright/

.gitlab-ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,28 @@ developer_tests:
3131
before_script:
3232
- python --version
3333
- apt-get update -y
34-
- apt-get install make -y
35-
- pip install ruff
34+
- apt-get install make curl git -y
35+
# Fetch main branch for comparison in typecheck-pr
36+
- git fetch origin main:main || echo "Could not fetch main branch"
37+
# Install uv
38+
- curl -LsSf https://astral.sh/uv/install.sh | sh
39+
- export PATH="$HOME/.cargo/bin:$PATH"
40+
# Create virtual environment
41+
- uv venv .venv
42+
- source .venv/bin/activate
43+
# Install Node.js and npm for basedpyright
44+
- curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
45+
- apt-get install -y nodejs
46+
- npm install -g basedpyright
47+
- uv pip install ruff
3648
# Install dependencies needed by publish.py for test imports
37-
- pip install typer rich boto3
49+
- uv pip install typer rich boto3
3850
# Install test dependencies
39-
- cd lib/idp_common_pkg && pip install -e ".[test]" && cd ../..
51+
- cd lib/idp_common_pkg && uv pip install -e ".[test]" && cd ../..
4052

4153
script:
4254
- make lint-cicd
55+
- make typecheck-cicd
4356
- make test-cicd -C lib/idp_common_pkg
4457

4558
artifacts:

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ check-arn-partitions:
7272
exit 1; \
7373
fi
7474

75+
# Type checking with basedpyright
76+
typecheck:
77+
@echo "Running type checks..."
78+
basedpyright
79+
80+
# Type check with detailed statistics
81+
typecheck-stats:
82+
@echo "Running type checks with statistics..."
83+
basedpyright --stats
84+
85+
# Type check only files changed in current PR/branch
86+
# Usage: make typecheck-pr [TARGET_BRANCH=branch_name]
87+
TARGET_BRANCH ?= main
88+
typecheck-pr:
89+
@echo "Type checking changed files against $(TARGET_BRANCH)..."
90+
python3 scripts/typecheck_pr_changes.py $(TARGET_BRANCH)
91+
92+
# CI/CD version of type check - checks PR changes only
93+
typecheck-cicd:
94+
@echo "Running type quality checks on PR changes..."
95+
@if ! python3 scripts/typecheck_pr_changes.py $(TARGET_BRANCH); then \
96+
echo -e "$(RED)ERROR: Type checking failed!$(NC)"; \
97+
echo -e "$(YELLOW)Please run 'make typecheck-pr' locally to fix these issues.$(NC)"; \
98+
exit 1; \
99+
fi
100+
@echo -e "$(GREEN)All type checks passed!$(NC)"
101+
75102
# A convenience Makefile target that runs
76103
commit: lint test
77104
$(info Generating commit message...)

idp_cli/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ version = "1.0.0"
1111
description = "Command-line interface for IDP Accelerator batch document processing"
1212
authors = [{name = "AWS"}]
1313
license = {text = "MIT-0"}
14-
requires-python = ">=3.9"
14+
requires-python = ">=3.10"
1515
classifiers = [
1616
"Development Status :: 4 - Beta",
1717
"Intended Audience :: Developers",
1818
"License :: OSI Approved :: MIT License",
1919
"Programming Language :: Python :: 3",
20-
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
2322
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
2424
]
2525
dependencies = [
2626
"click>=8.1.0",

lib/idp_common_pkg/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ name = "idp_common"
1919
version = "0.3.13"
2020
description = "Common utilities for GenAI IDP Accelerator patterns"
2121
authors = [{ name = "AWS", email = "noreply@amazon.com" }]
22-
requires-python = ">=3.9,<3.14"
22+
requires-python = ">=3.10,<3.14"
2323
dependencies = [
2424
"boto3==1.39.7", # Core dependency for AWS services
2525
"jsonschema>=4.25.1",

lib/idp_common_pkg/uv.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 50 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "accelerated-intelligent-document-processing",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Accelerated Intelligent Document Processing on AWS",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/aws-samples/accelerated-intelligent-document-processing-on-aws"
9+
},
10+
"license": "MIT-0",
11+
"devDependencies": {
12+
"basedpyright": "^1.32.1"
13+
},
14+
"scripts": {
15+
"typecheck": "basedpyright",
16+
"typecheck:watch": "basedpyright --watch",
17+
"typecheck:stats": "basedpyright --stats"
18+
},
19+
"engines": {
20+
"node": ">=18.0.0",
21+
"npm": ">=9.0.0"
22+
}
23+
}

pyrightconfig.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"include": [
3+
"lib/idp_common_pkg/idp_common",
4+
"idp_cli/idp_cli",
5+
"src/lambda"
6+
],
7+
8+
"exclude": [
9+
"**/node_modules",
10+
"**/__pycache__",
11+
"**/.venv",
12+
"**/.aws-sam",
13+
"**/build",
14+
"**/dist",
15+
"**/cdk.out",
16+
"notebooks",
17+
"patterns/*/src",
18+
"options/*/src"
19+
],
20+
21+
"pythonVersion": "3.12",
22+
"pythonPlatform": "Linux",
23+
24+
"typeCheckingMode": "basic",
25+
26+
"reportMissingImports": "warning",
27+
"reportMissingTypeStubs": "none",
28+
"reportImportCycles": "warning",
29+
"reportUnusedImport": "none",
30+
"reportUnusedVariable": "none",
31+
"reportDuplicateImport": "warning",
32+
"reportUndefinedVariable": "error",
33+
34+
"reportGeneralTypeIssues": "none",
35+
"reportOptionalMemberAccess": "none",
36+
"reportOptionalSubscript": "none",
37+
"reportPrivateImportUsage": "none",
38+
"reportUnknownMemberType": "none",
39+
"reportUnknownArgumentType": "none",
40+
"reportUnknownVariableType": "none",
41+
42+
"venvPath": ".",
43+
"venv": ".venv"
44+
}

0 commit comments

Comments
 (0)