mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-26 09:47:17 +01:00
Compare commits
4 Commits
42fa8228b0
...
a2644bace8
| Author | SHA1 | Date | |
|---|---|---|---|
| a2644bace8 | |||
| dadc2b3e6f | |||
| 7739d33532 | |||
| 8798105aa1 |
12
.file-length-exempt
Normal file
12
.file-length-exempt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Data files the 250-line cap reads as prose. In every one a line is a record,
|
||||||
|
# so splitting would corrupt it. Authored code beside them stays gated.
|
||||||
|
Programming/NLP/test_goldStandard/*/STSint.testinput.*.txt # official SemEval 2016 Task 2 iSTS test set, listed in test_goldStandard/00-README.txt
|
||||||
|
Programming/NLP/test_goldStandard/*/*-chunks-gpt-*.txt # recorded output of paid non-deterministic GPT runs (gpt_chunks.py); the experimental record
|
||||||
|
Programming/NLP/alignments_unformatted_*.txt # NLP pipeline stage data, one alignment per line, read by create_alignments.py and format_alignments.py
|
||||||
|
Programming/NLP/output.txt # NLP pipeline stage data, one record per line
|
||||||
|
Programming/NLP/reformated.txt # NLP pipeline stage data, one record per line
|
||||||
|
Programming/WDWR/projekt/old_code/data10000.txt # numeric matrix, 10000 scenario rows, solver input
|
||||||
|
Programming/WDWR/projekt/R/scenarios.txt # generated scenario vectors, one per line
|
||||||
|
Programming/WDWR/projekt/wdwr/solutions1.txt # CPLEX MILP solver log
|
||||||
|
Programming/WDWR/projekt/wdwr/KRZYSZTOF_RUDNICKI_307585_WDWR_PROJEKT/scenarios.txt # submitted copy of scenarios.txt, must stay byte-identical
|
||||||
|
Programming/WDWR/projekt/wdwr/KRZYSZTOF_RUDNICKI_307585_WDWR_PROJEKT/solutions1.txt # submitted copy of the CPLEX solver log, must stay byte-identical
|
||||||
2
.github/workflows/pre-commit.yml
vendored
2
.github/workflows/pre-commit.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
# scripts/check_md_naming.sh is a thin shim that execs the shared gate
|
# scripts/check_md_naming.sh is a thin shim that execs the shared gate
|
||||||
# out of the utils repo. A runner has no ~/utils, so without this the
|
# out of the utils repo. A runner has no ~/src/utils, so without this the
|
||||||
# hook fails with "shared gate not found".
|
# hook fails with "shared gate not found".
|
||||||
UTILS_ROOT: ${{ github.workspace }}/.utils
|
UTILS_ROOT: ${{ github.workspace }}/.utils
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
25
.github/workflows/repo-contract.yml
vendored
Normal file
25
.github/workflows/repo-contract.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: repo-contract
|
||||||
|
|
||||||
|
# The local pre-commit hook can be skipped (a fresh clone has no hooks), so the
|
||||||
|
# contract is enforced on push too. Mirrors md-naming.yml.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
repo-contract:
|
||||||
|
name: repo contract
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check out the shared gate
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: kuhyx/utils
|
||||||
|
path: .utils
|
||||||
|
|
||||||
|
- name: Enforce the repo contract
|
||||||
|
run: bash .utils/scripts/check_repo_contract.sh
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -489,3 +489,7 @@ gates/runnability-ci.tsv
|
|||||||
|
|
||||||
# Per-course virtualenvs created by ./run.sh run.
|
# Per-course virtualenvs created by ./run.sh run.
|
||||||
.venv/
|
.venv/
|
||||||
|
|
||||||
|
# test coverage output
|
||||||
|
.coverage
|
||||||
|
coverage.xml
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
# Ordering rule for this repo: a hook lands only once the thing it gates is
|
# Ordering rule for this repo: a hook lands only once the thing it gates is
|
||||||
# already clean, so `pre-commit run --all-files` is green at every commit.
|
# already clean, so `pre-commit run --all-files` is green at every commit.
|
||||||
# Hooks still to come, each blocked on its own cleanup:
|
# Hooks still to come, each blocked on its own cleanup:
|
||||||
# - file-length blocked on the .tex/code splits and TODO-file-length-250.md
|
# - file-length blocked on the .tex/code splits (27 files, TODO-refactor-remaining.md)
|
||||||
# - mypy the six third-party-typing errors are GONE (ERSMS moved
|
# - mypy the six third-party-typing errors are GONE (ERSMS moved
|
||||||
# to a typed DeclarativeBase; PSD has a scoped override).
|
# to a typed DeclarativeBase; PSD has a scoped override).
|
||||||
# Still blocked on ECOTE/NLP/EARIN, and on the fact that
|
# Still blocked on ECOTE/NLP/EARIN, and on the fact that
|
||||||
@ -67,6 +67,12 @@ repos:
|
|||||||
|
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
- id: repo-contract
|
||||||
|
name: repo contract (CLAUDE.md Commands + test_changed)
|
||||||
|
entry: scripts/check_repo_contract.sh
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
files: ^(CLAUDE\.md|AGENTS\.md|scripts/test_changed\.sh)$
|
||||||
# Coursework deliverables are allowed under the two course trees;
|
# Coursework deliverables are allowed under the two course trees;
|
||||||
# compiled output is allowed nowhere. See .binary-allowlist.
|
# compiled output is allowed nowhere. See .binary-allowlist.
|
||||||
- id: no-binaries
|
- id: no-binaries
|
||||||
@ -84,7 +90,7 @@ repos:
|
|||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
always_run: true
|
always_run: true
|
||||||
|
|
||||||
# Thin shim into ~/utils, which owns the four markdown namespaces.
|
# Thin shim into ~/src/utils, which owns the four markdown namespaces.
|
||||||
- id: md-naming
|
- id: md-naming
|
||||||
name: markdown naming convention
|
name: markdown naming convention
|
||||||
entry: scripts/check_md_naming.sh
|
entry: scripts/check_md_naming.sh
|
||||||
|
|||||||
15
CLAUDE.md
15
CLAUDE.md
@ -12,7 +12,7 @@ finished, and the value is that it still builds, runs and is readable.
|
|||||||
| `Programming/` | 25 course dirs with real code (Python, C/C++, Java, TS/Angular, C#, Unity, MATLAB-adjacent). |
|
| `Programming/` | 25 course dirs with real code (Python, C/C++, Java, TS/Angular, C#, Unity, MATLAB-adjacent). |
|
||||||
| `NotProgramming/` | 19 course dirs that are mostly LaTeX reports, PDFs and EDA schematics. Exceptions: `ENUME` (MATLAB), `STUP/makieta` (Angular), `EDABA-LAB` (SQL). |
|
| `NotProgramming/` | 19 course dirs that are mostly LaTeX reports, PDFs and EDA schematics. Exceptions: `ENUME` (MATLAB), `STUP/makieta` (Angular), `EDABA-LAB` (SQL). |
|
||||||
| `gates/` | Machine-readable gate inputs. `vendored.txt` is the source of truth for "not my code". |
|
| `gates/` | Machine-readable gate inputs. `vendored.txt` is the source of truth for "not my code". |
|
||||||
| `scripts/` | Repo-local gates. Shims that `exec` into `~/utils` live here too. |
|
| `scripts/` | Repo-local gates. Shims that `exec` into `~/src/utils` live here too. |
|
||||||
|
|
||||||
Two structural facts that surprise people:
|
Two structural facts that surprise people:
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ check.
|
|||||||
### Everything
|
### Everything
|
||||||
|
|
||||||
- **Every file is at most 250 lines, source and prose alike**, enforced by the
|
- **Every file is at most 250 lines, source and prose alike**, enforced by the
|
||||||
shared gate in `~/utils`. There is deliberately no baseline and no
|
shared gate in `~/src/utils`. There is deliberately no baseline and no
|
||||||
allowlist: split the file. For a LaTeX report that means `\input{}` per
|
allowlist: split the file. For a LaTeX report that means `\input{}` per
|
||||||
section; for a markdown report, sibling `DOCS-*.md` files behind an index.
|
section; for a markdown report, sibling `DOCS-*.md` files behind an index.
|
||||||
- **Coursework is held to the same bar as the tooling.** It gets the full
|
- **Coursework is held to the same bar as the tooling.** It gets the full
|
||||||
@ -102,7 +102,7 @@ check.
|
|||||||
`gates/vendored.txt` is the only place a path becomes exempt from lint,
|
`gates/vendored.txt` is the only place a path becomes exempt from lint,
|
||||||
coverage and the cap. Every entry carries a reason **and how it was
|
coverage and the cap. Every entry carries a reason **and how it was
|
||||||
verified** — an unverified entry is a suppression wearing a costume. The list
|
verified** — an unverified entry is a suppression wearing a costume. The list
|
||||||
is mirrored into `~/utils/file_length/_tables.py`, `[tool.ruff] exclude` and
|
is mirrored into `~/src/utils/file_length/_tables.py`, `[tool.ruff] exclude` and
|
||||||
`[tool.coverage.run] omit`; edit the manifest, never a mirror.
|
`[tool.coverage.run] omit`; edit the manifest, never a mirror.
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
@ -155,3 +155,12 @@ applies.
|
|||||||
| `.binary-allowlist` | Path-scoped: deliverables allowed under the two course trees, compiled output allowed nowhere. |
|
| `.binary-allowlist` | Path-scoped: deliverables allowed under the two course trees, compiled output allowed nowhere. |
|
||||||
| `DOCS-runnability.md` | Per-course run status, recorded separately for `local` and `ci`. |
|
| `DOCS-runnability.md` | Per-course run status, recorded separately for `local` and `ci`. |
|
||||||
| `TODO-*.md` | Open decisions. Each carries the removal marker and is deleted when the work lands. |
|
| `TODO-*.md` | Open decisions. Each carries the removal marker and is deleted when the work lands. |
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
- run: n/a: coursework archive; per course use `./run.sh run <dir>`
|
||||||
|
- test: `scripts/test_suites.sh`
|
||||||
|
- test-changed: `scripts/test_changed.sh`
|
||||||
|
- lint: `ruff check .`
|
||||||
|
- coverage: `COVERAGE=1 scripts/test_suites.sh`
|
||||||
|
- coverage-gaps: `coverage-gaps coverage.xml`
|
||||||
|
|||||||
@ -37,7 +37,7 @@ run cannot clobber the local column.
|
|||||||
| `Programming/EADS` | runnable | - | compiles each standalone .cpp |
|
| `Programming/EADS` | runnable | - | compiles each standalone .cpp |
|
||||||
| `Programming/EARIN` | runnable | - | python3 the entry script |
|
| `Programming/EARIN` | runnable | - | python3 the entry script |
|
||||||
| `Programming/ECOAR` | runnable | - | make |
|
| `Programming/ECOAR` | runnable | - | make |
|
||||||
| `Programming/ECOTE` | runnable | - | python3 /home/kuhy/WUT_Computer_Science/Programming/ECOTE/program/translator/main.py |
|
| `Programming/ECOTE` | runnable | - | python3 /home/kuhy/src/WUT_Computer_Science/Programming/ECOTE/program/translator/main.py |
|
||||||
| `Programming/ECRYPT` | no-code | - | test1.py is a 0-byte stub; this course produced no submitted code |
|
| `Programming/ECRYPT` | no-code | - | test1.py is a 0-byte stub; this course produced no submitted code |
|
||||||
| `Programming/ECRYPT_PROJECT` | runnable | - | python3 the entry script |
|
| `Programming/ECRYPT_PROJECT` | runnable | - | python3 the entry script |
|
||||||
| `Programming/EGUI` | runnable | - | dotnet build |
|
| `Programming/EGUI` | runnable | - | dotnet build |
|
||||||
@ -48,10 +48,10 @@ run cannot clobber the local column.
|
|||||||
| `Programming/ERSMS-project` | runnable | - | docker compose up |
|
| `Programming/ERSMS-project` | runnable | - | docker compose up |
|
||||||
| `Programming/NLP` | runnable | - | python3 the entry script |
|
| `Programming/NLP` | runnable | - | python3 the entry script |
|
||||||
| `Programming/PBAD` | blocked | - | jupyter is on PATH but does not run (dead shim) |
|
| `Programming/PBAD` | blocked | - | jupyter is on PATH but does not run (dead shim) |
|
||||||
| `Programming/PORR` | runnable | - | python3 /home/kuhy/WUT_Computer_Science/Programming/PORR/code/main.py |
|
| `Programming/PORR` | runnable | - | python3 /home/kuhy/src/WUT_Computer_Science/Programming/PORR/code/main.py |
|
||||||
| `Programming/PSD` | runnable | - | starts the Kafka/Flink stack (installs packages with sudo) |
|
| `Programming/PSD` | runnable | - | starts the Kafka/Flink stack (installs packages with sudo) |
|
||||||
| `Programming/psd_project` | runnable | - | mvn package |
|
| `Programming/psd_project` | runnable | - | mvn package |
|
||||||
| `Programming/TRAK` | runnable | - | python3 /home/kuhy/WUT_Computer_Science/Programming/TRAK/main.py |
|
| `Programming/TRAK` | runnable | - | python3 /home/kuhy/src/WUT_Computer_Science/Programming/TRAK/main.py |
|
||||||
| `Programming/twm_4` | blocked | - | jupyter is on PATH but does not run (dead shim) |
|
| `Programming/twm_4` | blocked | - | jupyter is on PATH but does not run (dead shim) |
|
||||||
| `Programming/USD` | no-code | - | README describes a MetaDrive RL assignment; no implementation was submitted |
|
| `Programming/USD` | no-code | - | README describes a MetaDrive RL assignment; no implementation was submitted |
|
||||||
| `Programming/WDWR` | runnable | - | python3 the entry script |
|
| `Programming/WDWR` | runnable | - | python3 the entry script |
|
||||||
|
|||||||
5
Makefile
Normal file
5
Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# finish gate hook: the root-level pytest cannot collect the ECRYPT sieve suite (relative CSVs), so
|
||||||
|
# the shared gate calls this target instead (see scripts/test_suites.sh).
|
||||||
|
.PHONY: cover
|
||||||
|
cover:
|
||||||
|
COVERAGE=1 scripts/test_suites.sh
|
||||||
@ -9,13 +9,16 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from collections.abc import Callable
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from collections.abc import Callable
|
||||||
|
|
||||||
# cv2.waitKey returns the ASCII code of the key pressed; 'q' quits.
|
# cv2.waitKey returns the ASCII code of the key pressed; 'q' quits.
|
||||||
KEY_Q = ord("q")
|
KEY_Q = ord("q")
|
||||||
# NumPy's legacy np.random.* functions share one global state; Generator is
|
# NumPy's legacy np.random.* functions share one global state; Generator is
|
||||||
|
|||||||
@ -466,7 +466,7 @@ def write_test_results(title: str, result: object = "") -> None:
|
|||||||
Path("test_results").mkdir(parents=True)
|
Path("test_results").mkdir(parents=True)
|
||||||
|
|
||||||
# Generate timestamped filename
|
# Generate timestamped filename
|
||||||
timestamp = datetime.datetime.now(tz=datetime.timezone.utc).strftime(
|
timestamp = datetime.datetime.now(tz=datetime.UTC).strftime(
|
||||||
"%Y%m%d%H%M%S"
|
"%Y%m%d%H%M%S"
|
||||||
) # e.g., 20230611235959
|
) # e.g., 20230611235959
|
||||||
filename = f"{title}_{timestamp}.txt"
|
filename = f"{title}_{timestamp}.txt"
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timezone
|
from datetime import UTC, datetime
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -89,9 +89,7 @@ MOVIES = Movies()
|
|||||||
@cache.cached(timeout=69)
|
@cache.cached(timeout=69)
|
||||||
def hello() -> ResponseReturnValue:
|
def hello() -> ResponseReturnValue:
|
||||||
"""Liveness check."""
|
"""Liveness check."""
|
||||||
return jsonify(
|
return jsonify({"response": "Hello there", "time": datetime.now(tz=UTC)}), HTTP_OK
|
||||||
{"response": "Hello there", "time": datetime.now(tz=timezone.utc)}
|
|
||||||
), HTTP_OK
|
|
||||||
|
|
||||||
|
|
||||||
# endpoint do wyciągania danych o userze
|
# endpoint do wyciągania danych o userze
|
||||||
|
|||||||
@ -8,10 +8,13 @@ them here would put newlines into the middle of the prompt itself.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
PROMPTS = Path(__file__).parent / "prompts"
|
PROMPTS = Path(__file__).parent / "prompts"
|
||||||
THE_PROMPT = (PROMPTS / "alignment.txt").read_text(encoding="utf-8")
|
THE_PROMPT = (PROMPTS / "alignment.txt").read_text(encoding="utf-8")
|
||||||
THE_PROMPT_WITH_COMMENT = (PROMPTS / "alignment_with_comment.txt").read_text(
|
THE_PROMPT_WITH_COMMENT = (PROMPTS / "alignment_with_comment.txt").read_text(
|
||||||
|
|||||||
@ -4,11 +4,15 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from collections.abc import Callable
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
from openai.types.chat import ChatCompletion
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from collections.abc import Callable
|
||||||
|
|
||||||
|
from openai.types.chat import ChatCompletion
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(format="%(message)s", level=logging.INFO)
|
logging.basicConfig(format="%(message)s", level=logging.INFO)
|
||||||
|
|||||||
@ -4,13 +4,16 @@
|
|||||||
import gc
|
import gc
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import linear_algebra_utils as lin_alg
|
import linear_algebra_utils as lin_alg
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from processing_type import ProcessingType
|
from processing_type import ProcessingType
|
||||||
from richardson_problem import Problem, Settings
|
|
||||||
from time_measurement import tests_time, time_accumulator, time_measurement
|
from time_measurement import tests_time, time_accumulator, time_measurement
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from richardson_problem import Problem, Settings
|
||||||
|
|
||||||
# These helpers are called with numpy arrays in some backends and plain
|
# These helpers are called with numpy arrays in some backends and plain
|
||||||
# Python lists in others, which is the point of the comparison this course
|
# Python lists in others, which is the point of the comparison this course
|
||||||
# is about, so the aliases name both.
|
# is about, so the aliases name both.
|
||||||
|
|||||||
@ -4,17 +4,20 @@
|
|||||||
import gc
|
import gc
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import linear_algebra_utils as lin_alg
|
import linear_algebra_utils as lin_alg
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numba import njit, prange
|
from numba import njit, prange
|
||||||
from richardson_problem import Problem, Settings
|
|
||||||
from time_measurement import (
|
from time_measurement import (
|
||||||
longest_threads_time_accumulator,
|
longest_threads_time_accumulator,
|
||||||
tests_time,
|
tests_time,
|
||||||
time_measurement_longest,
|
time_measurement_longest,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from richardson_problem import Problem, Settings
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Called with numpy arrays here and with plain lists in the sequential
|
# Called with numpy arrays here and with plain lists in the sequential
|
||||||
|
|||||||
@ -5,18 +5,22 @@ import gc
|
|||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import time
|
import time
|
||||||
from collections.abc import Callable
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import linear_algebra_utils as lin_alg
|
import linear_algebra_utils as lin_alg
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from richardson_problem import Problem, Settings
|
|
||||||
from time_measurement import (
|
from time_measurement import (
|
||||||
longest_threads_time_accumulator,
|
longest_threads_time_accumulator,
|
||||||
tests_time,
|
tests_time,
|
||||||
time_measurement_longest,
|
time_measurement_longest,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from collections.abc import Callable
|
||||||
|
|
||||||
|
from richardson_problem import Problem, Settings
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Called with numpy arrays here and with plain lists in the sequential
|
# Called with numpy arrays here and with plain lists in the sequential
|
||||||
|
|||||||
@ -7,15 +7,18 @@ import multiprocessing
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from richardson_problem import Problem, Settings
|
|
||||||
from time_measurement import (
|
from time_measurement import (
|
||||||
longest_time_accumulator,
|
longest_time_accumulator,
|
||||||
tests_time,
|
tests_time,
|
||||||
time_measurement_longest,
|
time_measurement_longest,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from richardson_problem import Problem, Settings
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Called with numpy arrays here and with plain lists in the sequential
|
# Called with numpy arrays here and with plain lists in the sequential
|
||||||
|
|||||||
@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from collections.abc import Callable
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from collections.abc import Callable
|
||||||
|
|
||||||
|
|
||||||
class TimeAccumulator:
|
class TimeAccumulator:
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from datetime import datetime, timezone
|
from datetime import UTC, datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class AlarmVisualizer:
|
|||||||
|
|
||||||
# Format the timestamp
|
# Format the timestamp
|
||||||
timestamp_dt = datetime.fromtimestamp(
|
timestamp_dt = datetime.fromtimestamp(
|
||||||
alarm.timestamp / MILLISECONDS, tz=timezone.utc
|
alarm.timestamp / MILLISECONDS, tz=UTC
|
||||||
).astimezone()
|
).astimezone()
|
||||||
formatted_date = timestamp_dt.strftime("%Y-%m-%d %H:%M:%S")
|
formatted_date = timestamp_dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
|||||||
@ -1,106 +0,0 @@
|
|||||||
# TODO: the 27 data `.txt` files the 250-line cap cannot classify
|
|
||||||
|
|
||||||
REMOVE ME AFTER FINISH
|
|
||||||
|
|
||||||
The 250-line cap applies to prose as well as code, and the shared gate treats
|
|
||||||
`.txt` as prose unless its mean line is under 25 characters (a wordlist). These
|
|
||||||
27 files are **data** with long lines, so the heuristic reads them as prose and
|
|
||||||
demands they be split. Splitting any of them corrupts it: in every one, a line
|
|
||||||
is a record.
|
|
||||||
|
|
||||||
Nothing here blocks the refactor. It blocks exactly one step — installing the
|
|
||||||
`file-length` pre-commit hook and workflow — so it must be settled before that
|
|
||||||
lands, and not before.
|
|
||||||
|
|
||||||
Run `bash ~/utils/scripts/check_file_length.sh --all` to see the current list.
|
|
||||||
|
|
||||||
## Why the existing mechanism does not cover them
|
|
||||||
|
|
||||||
`VENDORED_SUBPATHS` in `~/utils/file_length/_tables.py` matches **directory
|
|
||||||
prefixes** (`/{repo}/{sub}/`). That is enough for the 7 entries already in
|
|
||||||
`gates/vendored.txt`, and it is not enough here:
|
|
||||||
|
|
||||||
- `Programming/NLP/test_goldStandard/images/` holds the official SemEval corpus
|
|
||||||
**and** kuhy's own GPT outputs, side by side.
|
|
||||||
- `Programming/WDWR/projekt/R/` holds `scenarios.txt` (data) **and** `model.R`
|
|
||||||
(authored, 464 lines, must stay gated and covered).
|
|
||||||
|
|
||||||
A directory entry would exempt authored work in both cases. Per-file `# noqa`
|
|
||||||
style suppression is banned outright. So this needs a decision, not a workaround.
|
|
||||||
|
|
||||||
## The four categories
|
|
||||||
|
|
||||||
### 1. Official SemEval package — 12 files, genuinely third-party
|
|
||||||
|
|
||||||
The `STSint.testinput.{headlines,images,answers-students}.{sent1,sent2}[.chunk].txt`
|
|
||||||
files. Verified against the package's own manifest in
|
|
||||||
`Programming/NLP/test_goldStandard/00-README.txt`, which enumerates exactly
|
|
||||||
these, plus `evalF1.pl` and `wellformed.pl`, as the contents of the
|
|
||||||
"STS 2016 Task 2 Interpretable Semantic Textual Similarity TEST DATASET"
|
|
||||||
(authors: Eneko Agirre, Montse Maritxalar et al.).
|
|
||||||
|
|
||||||
Unambiguously vendored. The only question is *how* to express it.
|
|
||||||
|
|
||||||
### 2. kuhy's GPT outputs living inside the corpus directory — 6 files
|
|
||||||
|
|
||||||
```
|
|
||||||
Programming/NLP/test_goldStandard/headlines/headlines-chunks-gpt-{one,two}.txt
|
|
||||||
Programming/NLP/test_goldStandard/images/images-chunks-gpt-{one,two}.txt
|
|
||||||
Programming/NLP/test_goldStandard/student/students-chunks-gpt-{one,two}.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
**Not** in the package manifest — these are output from `gpt_chunks.py`, written
|
|
||||||
next to the corpus they were derived from. Regenerable in principle, but only by
|
|
||||||
re-running non-deterministic paid GPT calls, so untracking them destroys the
|
|
||||||
experimental record rather than saving space.
|
|
||||||
|
|
||||||
### 3. NLP pipeline data — 4 files
|
|
||||||
|
|
||||||
```
|
|
||||||
Programming/NLP/alignments_unformatted_headlines.txt 375 lines
|
|
||||||
Programming/NLP/alignments_unformatted_student.txt 344
|
|
||||||
Programming/NLP/output.txt 348
|
|
||||||
Programming/NLP/reformated.txt 348
|
|
||||||
```
|
|
||||||
|
|
||||||
Intermediate stage data. `alignments_unformatted_headlines.txt` is read as input
|
|
||||||
by `create_alignments.py:6` and `format_alignments.py:7`, so relocating these
|
|
||||||
costs exactly two path constants — the cheapest category to fix.
|
|
||||||
|
|
||||||
### 4. WDWR solver data and output — 5 files
|
|
||||||
|
|
||||||
```
|
|
||||||
Programming/WDWR/projekt/old_code/data10000.txt 10000 lines (numeric matrix, solver input)
|
|
||||||
Programming/WDWR/projekt/R/scenarios.txt 999 (generated scenario vectors)
|
|
||||||
Programming/WDWR/projekt/wdwr/solutions1.txt 3038 (CPLEX MILP solver log)
|
|
||||||
Programming/WDWR/projekt/wdwr/KRZYSZTOF_.../scenarios.txt 999 (submission copy)
|
|
||||||
Programming/WDWR/projekt/wdwr/KRZYSZTOF_.../solutions1.txt 3038 (submission copy)
|
|
||||||
```
|
|
||||||
|
|
||||||
Two of these live under `KRZYSZTOF_RUDNICKI_307585_WDWR_PROJEKT/`, the submitted
|
|
||||||
deliverable. Decision 6 of the approved plan says leave semantic duplicates
|
|
||||||
alone, so **relocation is not available for those two** — moving a file inside a
|
|
||||||
submission alters what was submitted.
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
**A. Extend the shared manifest to support file paths.** Teach
|
|
||||||
`~/utils/file_length/exemptions.py:is_vendored` to read `gates/vendored.txt` at
|
|
||||||
the repo root, supporting exact files as well as directories. This is the design
|
|
||||||
originally chosen (one root manifest consumed by every gate) and is the only
|
|
||||||
option that handles all four categories.
|
|
||||||
Cost: `file_length` currently has **zero tests** and no coverage job in
|
|
||||||
`.github/workflows/shared-gates-tests.yml`. Adding code to a gate 16 repos
|
|
||||||
depend on means authoring its test suite first.
|
|
||||||
|
|
||||||
**B. Relocate categories 2–4 into `data/` subdirectories** and add `data` to the
|
|
||||||
manifest per course dir. Cheap for categories 2 and 3. Cannot touch the two
|
|
||||||
WDWR submission-copy files. Does not address category 1.
|
|
||||||
|
|
||||||
**C. Accept a documented residual** — install the file-length gate with these 27
|
|
||||||
paths listed here, and treat the list as the record. Honest, but it is an
|
|
||||||
allowlist by another name, which the fleet rules reject.
|
|
||||||
|
|
||||||
Recommendation: **A**, taken as its own `~/utils` change with its own tests and
|
|
||||||
CI job, sequenced before Milestone 2 step 4. B as a fallback for categories 2–3
|
|
||||||
if A is judged too large, leaving categories 1 and 4 to a narrower version of A.
|
|
||||||
@ -3,14 +3,14 @@
|
|||||||
REMOVE ME AFTER FINISH
|
REMOVE ME AFTER FINISH
|
||||||
|
|
||||||
What is done, what is not, and the real numbers, re-measured 2026-08-28 after
|
What is done, what is not, and the real numbers, re-measured 2026-08-28 after
|
||||||
the lint campaign started. Companion to `TODO-file-length-250.md`, which parks
|
the lint campaign started. The 27 data `.txt` files the cap misread as prose
|
||||||
one specific blocking decision.
|
are exempted per file in `.file-length-exempt` (reason per entry, 2026-11-01).
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
| Area | State |
|
| Area | State |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Vendored manifest | `gates/vendored.txt`, 8 entries, mirrored into `~/utils` |
|
| Vendored manifest | `gates/vendored.txt`, 8 entries, mirrored into `~/src/utils` |
|
||||||
| Build artifacts | 189 untracked, `.gitignore` closed, 0 tracked-but-ignored files |
|
| Build artifacts | 189 untracked, `.gitignore` closed, 0 tracked-but-ignored files |
|
||||||
| no-binaries gate | Path-scoped `.binary-allowlist`; verified blocking AND passing |
|
| no-binaries gate | Path-scoped `.binary-allowlist`; verified blocking AND passing |
|
||||||
| Markdown | 4 namespaces, all under 250 lines, `CLAUDE.md` written |
|
| Markdown | 4 namespaces, all under 250 lines, `CLAUDE.md` written |
|
||||||
@ -150,12 +150,11 @@ fell out is a course that had never been run by the harness at all:
|
|||||||
|
|
||||||
## Still open
|
## Still open
|
||||||
|
|
||||||
### 1. The 250-line cap: 50 files
|
### 1. The 250-line cap: 27 files
|
||||||
|
|
||||||
| Type | Count | Note |
|
| Type | Count | Note |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `.txt` | 27 | Blocked -- see `TODO-file-length-250.md` |
|
| `.py` | 11 | Several GREW during the lint pass, because docstrings and annotations are lines: `NLP/gpt_chunks.py` 911 -> 973, `EARIN/lab2/main.py` 581 -> 647, `PORR/.../linear_algebra_utils.py` 422 -> 553. Split them AFTER the lint work, not during. TRAK is already clear: its three over-cap files were split in the same pass that linted them, each verified by a byte-identical render. `twm_4/TWM_KerasIntro.py` joined the list at 407 lines and should NOT be split: it is an nbconvert export, and a partial one |
|
||||||
| `.py` | 10 | Several GREW during the lint pass, because docstrings and annotations are lines: `NLP/gpt_chunks.py` 911 -> 973, `EARIN/lab2/main.py` 581 -> 647, `PORR/.../linear_algebra_utils.py` 422 -> 553. Split them AFTER the lint work, not during. TRAK is already clear: its three over-cap files were split in the same pass that linted them, each verified by a byte-identical render. `twm_4/TWM_KerasIntro.py` joined the list at 407 lines and should NOT be split: it is an nbconvert export, and a partial one |
|
|
||||||
| `.cpp` | 9 | |
|
| `.cpp` | 9 | |
|
||||||
| `.c` | 4 | |
|
| `.c` | 4 | |
|
||||||
| `.java` | 2 | |
|
| `.java` | 2 | |
|
||||||
|
|||||||
@ -23,7 +23,7 @@ Programming/BSS runnable builds the report with latexmk
|
|||||||
Programming/EADS runnable compiles each standalone .cpp
|
Programming/EADS runnable compiles each standalone .cpp
|
||||||
Programming/EARIN runnable python3 the entry script
|
Programming/EARIN runnable python3 the entry script
|
||||||
Programming/ECOAR runnable make
|
Programming/ECOAR runnable make
|
||||||
Programming/ECOTE runnable python3 /home/kuhy/WUT_Computer_Science/Programming/ECOTE/program/translator/main.py
|
Programming/ECOTE runnable python3 /home/kuhy/src/WUT_Computer_Science/Programming/ECOTE/program/translator/main.py
|
||||||
Programming/ECRYPT no-code test1.py is a 0-byte stub; this course produced no submitted code
|
Programming/ECRYPT no-code test1.py is a 0-byte stub; this course produced no submitted code
|
||||||
Programming/ECRYPT_PROJECT runnable python3 the entry script
|
Programming/ECRYPT_PROJECT runnable python3 the entry script
|
||||||
Programming/EGUI runnable dotnet build
|
Programming/EGUI runnable dotnet build
|
||||||
@ -34,10 +34,10 @@ Programming/E-PSYOPS runnable opens in the Unity editor
|
|||||||
Programming/ERSMS-project runnable docker compose up
|
Programming/ERSMS-project runnable docker compose up
|
||||||
Programming/NLP runnable python3 the entry script
|
Programming/NLP runnable python3 the entry script
|
||||||
Programming/PBAD blocked jupyter is on PATH but does not run (dead shim)
|
Programming/PBAD blocked jupyter is on PATH but does not run (dead shim)
|
||||||
Programming/PORR runnable python3 /home/kuhy/WUT_Computer_Science/Programming/PORR/code/main.py
|
Programming/PORR runnable python3 /home/kuhy/src/WUT_Computer_Science/Programming/PORR/code/main.py
|
||||||
Programming/PSD runnable starts the Kafka/Flink stack (installs packages with sudo)
|
Programming/PSD runnable starts the Kafka/Flink stack (installs packages with sudo)
|
||||||
Programming/psd_project runnable mvn package
|
Programming/psd_project runnable mvn package
|
||||||
Programming/TRAK runnable python3 /home/kuhy/WUT_Computer_Science/Programming/TRAK/main.py
|
Programming/TRAK runnable python3 /home/kuhy/src/WUT_Computer_Science/Programming/TRAK/main.py
|
||||||
Programming/twm_4 blocked jupyter is on PATH but does not run (dead shim)
|
Programming/twm_4 blocked jupyter is on PATH but does not run (dead shim)
|
||||||
Programming/USD no-code README describes a MetaDrive RL assignment; no implementation was submitted
|
Programming/USD no-code README describes a MetaDrive RL assignment; no implementation was submitted
|
||||||
Programming/WDWR runnable python3 the entry script
|
Programming/WDWR runnable python3 the entry script
|
||||||
|
|||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# THE source of truth for "not kuhy's code". Every gate reads this list:
|
# THE source of truth for "not kuhy's code". Every gate reads this list:
|
||||||
# - the 250-line cap and the md-naming gate, via the "WUT_Computer_Science"
|
# - the 250-line cap and the md-naming gate, via the "WUT_Computer_Science"
|
||||||
# key in VENDORED_SUBPATHS (~/utils/file_length/_tables.py)
|
# key in VENDORED_SUBPATHS (~/src/utils/file_length/_tables.py)
|
||||||
# - ruff, via [tool.ruff] exclude in pyproject.toml
|
# - ruff, via [tool.ruff] exclude in pyproject.toml
|
||||||
# - coverage, via [tool.coverage.run] omit
|
# - coverage, via [tool.coverage.run] omit
|
||||||
# - prettier, via .prettierignore
|
# - prettier, via .prettierignore
|
||||||
|
|||||||
@ -19,7 +19,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
readonly SCRIPT_DIR
|
readonly SCRIPT_DIR
|
||||||
readonly UTILS_ROOT="${UTILS_ROOT:-$HOME/utils}"
|
readonly UTILS_ROOT="${UTILS_ROOT:-$HOME/src/utils}"
|
||||||
|
|
||||||
CHECK_ONLY=0
|
CHECK_ONLY=0
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
# on its own, or the gates start disagreeing about what is kuhy's code.
|
# on its own, or the gates start disagreeing about what is kuhy's code.
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
target-version = "py310"
|
target-version = "py314"
|
||||||
line-length = 88
|
line-length = 88
|
||||||
include = ["*.py", "**/*.py", "*.ipynb", "**/*.ipynb"]
|
include = ["*.py", "**/*.py", "*.ipynb", "**/*.ipynb"]
|
||||||
|
|
||||||
|
|||||||
2
run.sh
2
run.sh
@ -196,7 +196,7 @@ cmd_sync_vendored() {
|
|||||||
log "gates/vendored.txt declares:"
|
log "gates/vendored.txt declares:"
|
||||||
grep -vE '^\s*#|^\s*$' "${SCRIPT_DIR}/gates/vendored.txt" | sed 's/^/ /'
|
grep -vE '^\s*#|^\s*$' "${SCRIPT_DIR}/gates/vendored.txt" | sed 's/^/ /'
|
||||||
printf '\nMirrored into:\n'
|
printf '\nMirrored into:\n'
|
||||||
printf ' ~/utils/file_length/_tables.py VENDORED_SUBPATHS["WUT_Computer_Science"]\n'
|
printf ' ~/src/utils/file_length/_tables.py VENDORED_SUBPATHS["WUT_Computer_Science"]\n'
|
||||||
printf ' pyproject.toml [tool.ruff] exclude (Milestone 4)\n'
|
printf ' pyproject.toml [tool.ruff] exclude (Milestone 4)\n'
|
||||||
printf ' pyproject.toml [tool.coverage.run] omit (Milestone 4)\n'
|
printf ' pyproject.toml [tool.coverage.run] omit (Milestone 4)\n'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Fail if any markdown file breaks the shared naming convention.
|
# Fail if any markdown file breaks the shared naming convention.
|
||||||
#
|
#
|
||||||
# Thin delegate to the shared gate in ~/utils, which owns the four namespaces
|
# Thin delegate to the shared gate in ~/src/utils, which owns the four namespaces
|
||||||
# (README / CLAUDE* / DOCS* / TODO*), the "REMOVE ME AFTER FINISH" marker rule
|
# (README / CLAUDE* / DOCS* / TODO*), the "REMOVE ME AFTER FINISH" marker rule
|
||||||
# and the exemption list. Copying that logic here is what lets one repo's idea
|
# and the exemption list. Copying that logic here is what lets one repo's idea
|
||||||
# of a valid name drift from every other repo's -- so this script only locates
|
# of a valid name drift from every other repo's -- so this script only locates
|
||||||
@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
readonly SHARED_GATE="${UTILS_ROOT:-$HOME/utils}/scripts/check_md_naming.sh"
|
readonly SHARED_GATE="${UTILS_ROOT:-$HOME/src/utils}/scripts/check_md_naming.sh"
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
if [[ ! -x "$SHARED_GATE" ]]; then
|
if [[ ! -x "$SHARED_GATE" ]]; then
|
||||||
echo "Error: shared markdown-naming gate not found at $SHARED_GATE" >&2
|
echo "Error: shared markdown-naming gate not found at $SHARED_GATE" >&2
|
||||||
echo " Clone github.com/kuhyx/utils to ~/utils, or set" >&2
|
echo " Clone github.com/kuhyx/utils to ~/src/utils, or set" >&2
|
||||||
echo " UTILS_ROOT to where it lives." >&2
|
echo " UTILS_ROOT to where it lives." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Pre-commit hook: block binary and image files from being committed.
|
# Pre-commit hook: block binary and image files from being committed.
|
||||||
#
|
#
|
||||||
# Copied from ~/testsAndMisc/meta/scripts/check_no_binaries.sh, which is where
|
# Copied from ~/src/testsAndMisc/meta/scripts/check_no_binaries.sh, which is where
|
||||||
# this gate lives today (it is NOT in the shared ~/utils gate set). Keep the two
|
# this gate lives today (it is NOT in the shared ~/src/utils gate set). Keep the two
|
||||||
# in step, and prefer moving it to ~/utils over letting them drift -- a
|
# in step, and prefer moving it to ~/src/utils over letting them drift -- a
|
||||||
# hand-copied gate is exactly what produced four forks of the 250-line cap.
|
# hand-copied gate is exactly what produced four forks of the 250-line cap.
|
||||||
#
|
#
|
||||||
# Only the remedy text differs: "move it to a sibling _binaries/ dir" is wrong
|
# Only the remedy text differs: "move it to a sibling _binaries/ dir" is wrong
|
||||||
|
|||||||
26
scripts/check_repo_contract.sh
Executable file
26
scripts/check_repo_contract.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Fail if this repo breaks the shared repo contract.
|
||||||
|
#
|
||||||
|
# Thin delegate to the shared gate in ~/src/utils, which owns the contract
|
||||||
|
# text. Copy this file to scripts/check_repo_contract.sh in a repo; never copy
|
||||||
|
# the shared gate itself, or the shim would exec itself forever.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly SHARED_GATE="${UTILS_ROOT:-$HOME/src/utils}/scripts/check_repo_contract.sh"
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if [[ ! -x "$SHARED_GATE" ]]; then
|
||||||
|
echo "Error: shared repo-contract gate not found at $SHARED_GATE" >&2
|
||||||
|
echo " Clone github.com/kuhyx/utils to ~/src/utils, or set" >&2
|
||||||
|
echo " UTILS_ROOT to where it lives." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec bash "$SHARED_GATE" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
32
scripts/test_changed.sh
Executable file
32
scripts/test_changed.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Run only the pytest suites whose directory has changes vs HEAD (staged,
|
||||||
|
# unstaged and untracked). Quiet: failures plus a one-line summary per suite.
|
||||||
|
# Changes to shared config (pyproject.toml, this repo's test scripts) run all
|
||||||
|
# suites; changes outside any suite run nothing.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
readonly ROOT
|
||||||
|
readonly SUITES=(Programming/ECOTE Programming/ECRYPT_PROJECT/sieve)
|
||||||
|
|
||||||
|
changed="$(cd "$ROOT" && { git diff --name-only HEAD 2>/dev/null || true; git ls-files --others --exclude-standard; } | sort -u)"
|
||||||
|
selected=()
|
||||||
|
all=0
|
||||||
|
for s in "${SUITES[@]}"; do
|
||||||
|
grep -q "^${s}/" <<<"$changed" && selected+=("$s")
|
||||||
|
done
|
||||||
|
grep -Eq '^(pyproject\.toml|scripts/test_suites\.sh|scripts/test_changed\.sh)$' <<<"$changed" && all=1
|
||||||
|
|
||||||
|
if [[ $all -eq 1 ]]; then
|
||||||
|
echo "shared test config changed: running all suites"
|
||||||
|
exec "$ROOT/scripts/test_suites.sh"
|
||||||
|
fi
|
||||||
|
if [[ ${#selected[@]} -eq 0 ]]; then
|
||||||
|
echo "no changes in a pytest suite: nothing to test"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
SUITE_DIRS="${selected[*]}" exec "$ROOT/scripts/test_suites.sh"
|
||||||
40
scripts/test_suites.sh
Executable file
40
scripts/test_suites.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Run the pytest suites that exist in this archive, each from its own directory
|
||||||
|
# (ECRYPT sieve reads its reference CSVs by relative path, so a repo-root
|
||||||
|
# `pytest` cannot collect it). Extra args are passed to every pytest run.
|
||||||
|
# Usage: scripts/test_suites.sh [pytest args]
|
||||||
|
# COVERAGE=1 scripts/test_suites.sh # writes coverage.xml at repo root
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
readonly ROOT
|
||||||
|
readonly SUITES=(Programming/ECOTE Programming/ECRYPT_PROJECT/sieve)
|
||||||
|
|
||||||
|
run_suites() {
|
||||||
|
local -a suites=("$@") extra=()
|
||||||
|
[[ ${#suites[@]} -eq 0 ]] && suites=("${SUITES[@]}")
|
||||||
|
if [[ "${COVERAGE:-0}" == 1 ]]; then
|
||||||
|
export COVERAGE_FILE="$ROOT/.coverage"
|
||||||
|
rm -f "$COVERAGE_FILE" "$ROOT/coverage.xml"
|
||||||
|
fi
|
||||||
|
local rc=0 s
|
||||||
|
for s in "${suites[@]}"; do
|
||||||
|
if [[ "${COVERAGE:-0}" == 1 ]]; then
|
||||||
|
extra=(--cov="$ROOT/$s" --cov-branch --cov-append --cov-config="$ROOT/pyproject.toml")
|
||||||
|
fi
|
||||||
|
(cd "$ROOT/$s" && python3 -m pytest -q --tb=short "${extra[@]}" "${PYTEST_ARGS[@]}") || rc=$?
|
||||||
|
done
|
||||||
|
if [[ "${COVERAGE:-0}" == 1 ]]; then
|
||||||
|
(cd "$ROOT" && python3 -m coverage xml -o coverage.xml --rcfile=pyproject.toml >/dev/null)
|
||||||
|
fi
|
||||||
|
return "$rc"
|
||||||
|
}
|
||||||
|
|
||||||
|
PYTEST_ARGS=("$@")
|
||||||
|
[[ -n "${SUITE_DIRS:-}" ]] && read -r -a SELECTED <<<"$SUITE_DIRS" || SELECTED=()
|
||||||
|
run_suites "${SELECTED[@]}"
|
||||||
|
exit $?
|
||||||
Loading…
Reference in New Issue
Block a user