Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b2d2cbe
add mega-linter action
briochesoft Oct 29, 2025
d234b03
.mega-linter.yml: remove grype, too long, not necessary
briochesoft Oct 31, 2025
95995ec
Add cspell configuration
briochesoft Oct 31, 2025
9a06e72
Add jscpd configuration
briochesoft Oct 31, 2025
6a8be9b
Add python tools configuration file
briochesoft Nov 7, 2025
f357287
Dockerfile: fix install
briochesoft Oct 30, 2025
ade7d9d
Dockerfile: use abricks user
briochesoft Oct 30, 2025
bd530de
Dockerfile: add healthcheck
briochesoft Oct 30, 2025
1a2beb8
README.md: add language to fenced code blocks
briochesoft Oct 31, 2025
da03fa6
README.md: fix script name to run
briochesoft Oct 31, 2025
3317001
inputinterface: extension return a string
briochesoft Nov 4, 2025
23bb465
input: rename parameter to file_path
briochesoft Nov 4, 2025
5035024
input: handle unused argument
briochesoft Nov 4, 2025
fa89d52
input: change exception type when format is not handled
briochesoft Nov 10, 2025
e65381c
assortedbricks: add timeouts for requests.get
briochesoft Oct 31, 2025
b5eddb4
assortedbricks: use relative path in __main__.py
briochesoft Nov 4, 2025
dd7797e
assortedbricks: keep database open during inventory life time
briochesoft Nov 4, 2025
ff773f4
assortedbricks: rename set variable to set_number
briochesoft Nov 5, 2025
ce4ca4e
assortedbricks: remove unnecessary pass
briochesoft Nov 5, 2025
30a59ee
assortedbricks: reorder imports
briochesoft Nov 5, 2025
4e099c0
assortedbricks: adapt to future copy-on-write behavior in Pandas
briochesoft Nov 10, 2025
e28eef3
config: clean key retrieval function
briochesoft Nov 5, 2025
2b235c6
rebrickableset: explicitly re-raise exceptions
briochesoft Nov 5, 2025
9a67844
rebrickableset: add encoding when writing file
briochesoft Nov 5, 2025
ebe1c75
inventory: correctly initialize DataFrame
briochesoft Nov 4, 2025
843b12f
inventory: clarify load() arguments
briochesoft Nov 5, 2025
15589d3
inventory: simplify labels counting
briochesoft Nov 5, 2025
31af9c8
database: use sqlalchemy for sql interactions
briochesoft Oct 31, 2025
81822bb
.gitignore: ignore megalinter reports
briochesoft Nov 6, 2025
2b00749
[MegaLinter] Apply linters fixes
briochesoft Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"version": "0.2",
"language": "en",
"ignorePaths": [
"**/node_modules/**",
"**/vscode-extension/**",
"**/.git/**",
"**/.pnpm-lock.json",
".vscode",
"package-lock.json",
"megalinter-reports"
],
"words": [
"Brickstore",
"PYLINT",
"Rebrickable",
"abricks",
"adduser",
"assortedbricks",
"autoremove",
"beautifulsoup",
"brickarchitect",
"brickstorexml",
"chapternav",
"directroy",
"dotenv",
"enctype",
"gethostname",
"hirarchy",
"inputinterface",
"kmeans",
"ldcadpbg",
"liveconsole",
"lxml",
"optionnaly",
"partid",
"pycache",
"pyenv",
"pylintrc",
"pyproject",
"pyrightconfig",
"pysqlite",
"pyyaml",
"rebrickable",
"rebrickablecsv",
"rebrickablejson",
"rebrickableset",
"scikit",
"sqlalchemy",
"stefanzweifel",
"subarray",
"temporpary",
"venv",
"virtualenv"
]
}
172 changes: 172 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# MegaLinter GitHub Action configuration file
# More info at https://megalinter.io
---
name: MegaLinter

# Trigger mega-linter at every push. Action will also be visible from Pull
# Requests to main
on: # yamllint disable-line rule:truthy - false positive
# Comment this line to trigger action only on pull-requests
# (not recommended if you don't pay for GH Actions)
push:

pull_request:
branches:
- main
- master

# Comment env block if you do not want to apply fixes
env:
# Apply linter fixes configuration
#
# When active, APPLY_FIXES must also be defined as environment variable
# (in github/workflows/mega-linter.yml or other CI tool)
APPLY_FIXES: all

# Decide which event triggers application of fixes in a commit or a PR
# (pull_request, push, all)
APPLY_FIXES_EVENT: pull_request

# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
# or posted in a PR (pull_request)
APPLY_FIXES_MODE: commit

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

permissions: {}

jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest

# Give the default GITHUB_TOKEN write permission to commit and push, comment
# issues & post new PR; remove the ones you do not need
permissions:
contents: write
issues: write
pull-requests: write

steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v5
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
# improve performance
fetch-depth: 0

# MegaLinter
- name: MegaLinter

# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/latest/flavors/
uses: oxsecurity/megalinter@62c799d895af9bcbca5eacfebca29d527f125a57

id: ml

# All available variables are described in documentation
# https://megalinter.io/latest/configuration/
env:
# Validates all source when push on main, else just the git diff with
# main. Override with true if you always want to lint all sources
#
# To validate the entire codebase, set to:
# VALIDATE_ALL_CODEBASE: true
#
# To validate only diff with main, set to:
# VALIDATE_ALL_CODEBASE: >-
# ${{
# github.event_name == 'push' &&
# contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
# }}
VALIDATE_ALL_CODEBASE: true

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY

# Uncomment to disable copy-paste and spell checks
# DISABLE: COPYPASTE,SPELL

# Upload MegaLinter artifacts
- name: Archive production artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: MegaLinter reports
include-hidden-files: "true"
path: |
megalinter-reports
mega-linter.log

# Set APPLY_FIXES_IF var for use in future steps
- name: Set APPLY_FIXES_IF var
run: |
printf 'APPLY_FIXES_IF=%s\n' "${{
steps.ml.outputs.has_updated_sources == 1 &&
(
env.APPLY_FIXES_EVENT == 'all' ||
env.APPLY_FIXES_EVENT == github.event_name
) &&
(
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}" >> "${GITHUB_ENV}"

# Set APPLY_FIXES_IF_* vars for use in future steps
- name: Set APPLY_FIXES_IF_* vars
run: |
printf 'APPLY_FIXES_IF_PR=%s\n' "${{
env.APPLY_FIXES_IF == 'true' &&
env.APPLY_FIXES_MODE == 'pull_request'
}}" >> "${GITHUB_ENV}"
printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{
env.APPLY_FIXES_IF == 'true' &&
env.APPLY_FIXES_MODE == 'commit' &&
(!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref))
}}" >> "${GITHUB_ENV}"

# Create pull request if applicable
# (for now works only on PR from same repository, not from forks)
- name: Create Pull Request with applied fixes
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
id: cpr
if: env.APPLY_FIXES_IF_PR == 'true'
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot

- name: Create PR output
if: env.APPLY_FIXES_IF_PR == 'true'
run: |
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"

# Push new commit if applicable
# (for now works only on PR from same repository, not from forks)
- name: Prepare commit
if: env.APPLY_FIXES_IF_COMMIT == 'true'
run: sudo chown -Rc $UID .git/

- name: Commit and push applied linter fixes
uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3
if: env.APPLY_FIXES_IF_COMMIT == 'true'
with:
branch: >-
${{
github.event.pull_request.head.ref ||
github.head_ref ||
github.ref
}}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: megalinter-bot
commit_user_email: 129584137+megalinter-bot@users.noreply.github.com
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ __pycache__/
# virtualenv
.venv
venv/
ENV/
ENV/

# lint
megalinter-reports/
3 changes: 3 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore": ["**/assortedbricks/input/**"]
}
5 changes: 5 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DISABLE_LINTERS:
- REPOSITORY_GRYPE

PYTHON_BANDIT_CONFIG_FILE: pyproject.toml
PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
FROM python:3-slim

WORKDIR /usr/src/assortedbricks
RUN adduser abricks

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
WORKDIR /home/abricks

COPY . .

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential=12.12 \
&& pip install --no-cache-dir -r requirements.txt \
&& apt-get --purge -y autoremove build-essential \
&& rm -rf /var/lib/apt/lists/*


USER abricks

HEALTHCHECK CMD bash -c "exec 6<> /dev/tcp/localhost/5000"

CMD [ "./run-assortedbricks" ]

EXPOSE 5000
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ I found [brickarchitect](https://brickarchitect.com/), and it provided the perfe

## Installation

```
```bash
python3 -m venv .env
source .env/bin/activate
pip install -r requirements.txt
```

## Usage

```
```bash
source .env/bin/activate
./run-assortedbrick
./run-assortedbricks
```

Then connect to ```http://localhost:5000```
Then connect to ```http://localhost:5000```

Give a set number or choose an inventory file, the number of clusters to generate and optionnaly a seed for the clustering algorithm.

The set number input is only available is a Rebrickable API key has been configured in the ``config.yaml`` file:

``
```yaml
rebrickable-key: "KEY"
``
```

Supported file formats are:
- Rebrickable CSV
- Brickstore XML
- LDCad PBG
- Rebrickable CSV
- Brickstore XML
- LDCad PBG

## Acknowledgement

Special thanks to [brickarchitect](https://brickarchitect.com/) for the excellent data.
Special thanks to [brickarchitect](https://brickarchitect.com/) for the excellent data.
8 changes: 4 additions & 4 deletions assortedbricks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#
# SPDX-License-Identifier: MIT
"""
The main entry point of assortedbricks
The main entry point of assortedbricks
"""

from assortedbricks import main
from .assortedbricks import main

__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2025, BriocheSoft'
__license__ = "MIT"
__copyright__ = "Copyright (c) 2025, BriocheSoft"

main()
Loading