Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
croqaz committed Jan 12, 2025
1 parent c550dde commit 43b697c
Show file tree
Hide file tree
Showing 9 changed files with 1,097 additions and 225 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ jobs:
with:
python-version: 3.13

- name: Install dependencies
run: |
curl -sSf https://rye.astral.sh/get | bash
rye sync
- name: Lint code
run: |
make lint
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Run tests
run: |
Expand All @@ -32,6 +26,10 @@ jobs:
run: |
make coverage
- name: Lint code
run: |
make lint
- name: Publish coverage
uses: codecov/codecov-action@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ clean:
rm -rf dist

lint:
ruff check imgdb/ test/
uv run ruff check imgdb/ test/

coverage:
rye run pytest --cov-report term --cov-report xml --cov=imgdb/ test/
uv run pytest --cov-report term --cov-report xml --cov=imgdb/ test/

test:
rye run pytest -ra -sv test/
uv run pytest -ra -sv test/
4 changes: 3 additions & 1 deletion imgdb/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def top_colors(img: Image.Image, cut=TOP_COLOR_CUT) -> list:
total = len(collect_colors)
# stat = {k: round(v / total * 100, 1) for k, v in Counter(collect_colors).items() if v / total * 100 >= cut}
# log.info(f'Collected {len(set(collect_colors)):,} uniq colors, cut to {len(stat):,} colors')
return [f'{k[-1]}={round(v/total*100, 1)}' for k, v in Counter(collect_colors).items() if v / total * 100 >= cut]
return [
f'{k[-1]}={round(v / total * 100, 1)}' for k, v in Counter(collect_colors).items() if v / total * 100 >= cut
]


def closest_color(pair: tuple, split=TOP_CLR_ROUND_TO) -> tuple:
Expand Down
2 changes: 1 addition & 1 deletion imgdb/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def db_save(db_or_el, fname: str, sort_by='date'):
):
imgs.append(el)
htm = DB_TMPL.format('\n'.join(str(el) for el in imgs))
log.debug(f'Saving {len(imgs):,} imgs, disk size {len(htm)//1024:,} KB')
log.debug(f'Saving {len(imgs):,} imgs, disk size {len(htm) // 1024:,} KB')
return open(fname, 'w').write(htm)


Expand Down
2 changes: 1 addition & 1 deletion imgdb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def generate_gallery(c: Config):
metas, imgs = db_filter(db, c=c)

max_pages = len(metas) // c.wrap_at
log.info(f'Generating {max_pages+1} galleries from {len(metas):,} pictures...')
log.info(f'Generating {max_pages + 1} galleries from {len(metas):,} pictures...')

# add or remove attrs before publishing gallery
for img in imgs:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ build-backend = "hatchling.build"
use-uv = true
autosync = true

[tool.rye]
dev-dependencies = [
[dependency-groups]
dev = [
"hatch ~= 1.14",
"ruff ~= 0.8",
"pytest ~= 8.3",
Expand Down
167 changes: 0 additions & 167 deletions requirements-dev.lock

This file was deleted.

42 changes: 0 additions & 42 deletions requirements.lock

This file was deleted.

Loading

0 comments on commit 43b697c

Please sign in to comment.