-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
groups: | ||
patches: | ||
update-types: | ||
- "minor" | ||
- "patch" | ||
open-pull-requests-limit: 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: On Push Workflow | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
uv-sync: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: UV sync | ||
id: uv-sync | ||
# a new commit will not trigger this workflow again | ||
run: | | ||
pipx install uv | ||
./bin/uv-sync.sh | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: uv-sync | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install UV | ||
run: | | ||
pipx install uv | ||
- name: Run tests | ||
run: | | ||
uv run pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Python-generated files | ||
__pycache__/ | ||
*.py[oc] | ||
build/ | ||
dist/ | ||
wheels/ | ||
*.egg-info | ||
|
||
# Virtual environments | ||
.venv | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
PYTHON_VERSION=$(cat .python-version) | ||
BRANCH_NAME=${GITHUB_REF#refs/heads/} | ||
AUTHOR_NAME=$(git log -1 --pretty=format:"%an") | ||
AUTHOR_EMAIL=$(git log -1 --pretty=format:"%ae") | ||
|
||
if [[ "$AUTHOR_NAME" == *dependabot* ]] ; then | ||
# Read requirements.txt, exclude comments, and format as TOML array | ||
constraints=$(grep -vE '^\s*#' requirements.txt | awk '{print " \""$0"\","}') | ||
|
||
# Append constraint-dependencies to pyproject.toml | ||
cat <<EOF >> pyproject.toml | ||
[tool.uv] | ||
constraint-dependencies = [ | ||
$constraints | ||
] | ||
EOF | ||
|
||
echo "Lock uv with a new requirements.txt as constraint" | ||
uv lock | ||
fi | ||
|
||
echo "Export uv.lock to requirements.txt" | ||
uv export --no-hashes -o requirements.txt | ||
|
||
# Add pip-compile like comment to the top of requirements.txt | ||
# for dependabot to detect a pip-compile workflow | ||
cat << EOF | cat - requirements.txt > temp && mv temp requirements.txt | ||
# | ||
# This file is autogenerated by pip-compile with Python $PYTHON_VERSION | ||
# by the following command: | ||
# | ||
# pip-compile pyproject.toml | ||
# | ||
# | ||
# The above comment was added for dependabot to support uv. | ||
# | ||
EOF | ||
|
||
git add uv.lock requirements.txt | ||
if ! git diff --cached --quiet; then | ||
# git config --global user.name "$AUTHOR_NAME" | ||
# git config --global user.email "$AUTHOR_EMAIL" | ||
# git commit -m "Sync uv.lock and requirements.txt" | ||
# git push origin $BRANCH_NAME | ||
echo "push changes" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from uv_light.lens import Lens | ||
from uv_light.beam import Beam | ||
|
||
if __name__ == "main": | ||
print(Beam().project_on(Lens())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[project] | ||
name = "uv-light" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
readme = "README.md" | ||
requires-python = ">=3.12" | ||
dependencies = [ | ||
"flask==3.*", | ||
"pandas==2.*", | ||
"pyarrow==17.*", | ||
"pytest>=8.3.3", | ||
] |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from uv_light.beam import Beam | ||
from uv_light.lens import Lens | ||
|
||
def test_beam_project_on(): | ||
actual = Beam().project_on(Lens()) | ||
expected = "~~~|--->\n~~~|--->\n~~~|--->\n~~~|--->" | ||
assert actual == expected |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pandas as pd | ||
import pyarrow as pa | ||
|
||
class Beam: | ||
def __init__(self): | ||
# Represent the beam with an arrow | ||
self.beam_pattern = pa.array(["--->", "--->", "--->", "--->"]) | ||
|
||
def project_on(self, lens): | ||
# Convert pyarrow array to pandas DataFrame | ||
beam_frame = pd.DataFrame({'Beam': self.beam_pattern.to_pandas()}) | ||
return lens.focus_beam(beam_frame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pandas as pd | ||
|
||
class Lens: | ||
def focus_beam(self, beam_frame): | ||
# Add lens symbol to the DataFrame | ||
beam_frame['Lens'] = '~~~|' | ||
# Combine Beam and Lens columns into a single string representation | ||
beam_frame['Projection'] = beam_frame['Lens'] + beam_frame['Beam'] | ||
return beam_frame['Projection'].to_string(index=False, header=False) |