Skip to content

Commit eb0cb06

Browse files
authored
Merge pull request #322 from MC-kit/devel
Devel
2 parents b14721f + 3b52b10 commit eb0cb06

File tree

9 files changed

+1013
-352
lines changed

9 files changed

+1013
-352
lines changed

.github/workflows/release-drafter.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ jobs:
77
draft_release:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: release-drafter/release-drafter@v5
10+
- uses: release-drafter/release-drafter@v6
1111
env:
1212
GITHUB_TOKEN: ${{ secrets.MCKIT_GITHUB_TOKEN }}

.github/workflows/release.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,14 @@ jobs:
7171
7272
- name: Publish package on PyPI
7373
if: steps.check-version.outputs.tag
74-
uses: pypa/gh-action-pypi-publish@release/v1
75-
with:
76-
user: __token__
77-
password: ${{ secrets.PYPI_TOKEN }}
74+
run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
7875

7976
- name: Publish package on TestPyPI
8077
if: "! steps.check-version.outputs.tag"
81-
uses: pypa/gh-action-pypi-publish@release/v1
82-
with:
83-
user: __token__
84-
password: ${{ secrets.TEST_PYPI_TOKEN }}
85-
repository_url: https://test.pypi.org/legacy/
78+
run: poetry publish --username=__token__ --password=${{ secrets.TEST_PYPI_TOKEN }}
8679

8780
- name: Publish the release notes
88-
uses: release-drafter/release-drafter@v5
81+
uses: release-drafter/release-drafter@v6
8982
with:
9083
publish: ${{ steps.check-version.outputs.tag != '' }}
9184
tag: ${{ steps.check-version.outputs.tag }}

.github/workflows/tests.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
5959
- name: Load poetry cache
6060
id: cached-poetry-dependencies
61-
uses: actions/cache@v3
61+
uses: actions/cache@v4
6262
with:
6363
path: |
6464
.cache/pypoetry
@@ -105,7 +105,7 @@ jobs:
105105
106106
- name: Load poetry cache
107107
id: cached-poetry-dependencies
108-
uses: actions/cache@v3
108+
uses: actions/cache@v4
109109
with:
110110
path: |
111111
.cache/pypoetry
@@ -159,7 +159,7 @@ jobs:
159159
160160
- name: Load poetry cache
161161
id: cached-poetry-dependencies
162-
uses: actions/cache@v3
162+
uses: actions/cache@v4
163163
with:
164164
path: |
165165
.cache/pypoetry
@@ -202,7 +202,7 @@ jobs:
202202
203203
- name: Load poetry cache
204204
id: cached-poetry-dependencies
205-
uses: actions/cache@v3
205+
uses: actions/cache@v4
206206
with:
207207
path: |
208208
.cache/pypoetry
@@ -236,4 +236,4 @@ jobs:
236236
nox --force-color --session=coverage -- xml
237237
238238
- name: Upload coverage report
239-
uses: codecov/codecov-action@v3.1.4
239+
uses: codecov/codecov-action@v4

.pre-commit-config.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ repos:
4747
rev: "v1.5.4"
4848
hooks:
4949
- id: remove-tabs
50+
5051
# Format doc strings
5152
- repo: https://github.com/DanielNoord/pydocstringformatter
5253
rev: "v0.7.3"
5354
hooks:
5455
- id: pydocstringformatter
55-
exclude: _parser\.py$|_tab\.py
56+
exclude: _parser\.py$|_tab\.py|extern
5657

5758
- repo: local
5859
hooks:
5960
# Upgrade Python code
6061
- id: pyupgrade
6162
name: pyupgrade
62-
exclude: \.idea|\.cache|^notebooks
63+
exclude: \.idea|\.cache|^notebooks|^extern
6364
entry: pyupgrade
6465
args:
6566
- --py39-plus
@@ -69,7 +70,7 @@ repos:
6970
# Nicely sort imports
7071
- id: isort
7172
name: isort
72-
exclude: tools|\.idea|\.cache|^notebooks
73+
exclude: tools|\.idea|\.cache|^notebooks|^extern
7374
entry: isort
7475
language: system
7576
types: [ python ]
@@ -80,15 +81,15 @@ repos:
8081
entry: black
8182
language: system
8283
types: [ python ]
83-
exclude: ^notebooks
84+
exclude: ^notebooks|^extern
8485

8586
# Lint and fix Python code
8687
- id: ruff
8788
name: ruff
8889
entry: ruff --force-exclude --fix --config pyproject.toml
8990
language: system
9091
types: [ python ]
91-
exclude: ^notebooks
92+
exclude: ^notebooks|^extern
9293

9394
# Lint SQL code
9495
- id: sqlfluff-lint

README.rst

+50-4
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,59 @@ Examples
7777
7878
jsons = [path1, path2, ...]
7979
material_ids = {p: get_material_id(p) for p in jsons }
80-
case_ids = {c:: get_case_id(p) for p in jsons
80+
case_ids = {c: get_case_id(p) for p in jsons }
8181
8282
collector = FullDataCollector()
8383
84-
for json in jsons:
85-
inventory = Inventory.from_json(json)
86-
collector.append(inventory, material_id=material_ids[json], case_id=case_ids[json])
84+
if sequential_load:
85+
for json in jsons:
86+
inventory = Inventory.from_json(json)
87+
collector.append(inventory, material_id=material_ids[json], case_id=case_ids[json])
88+
89+
else: # multithreading is allowed for collector as well
90+
91+
task_list = ... # list of tuples[directory, case_id, tasks_sequence]
92+
threads = 16 # whatever
93+
94+
def _find_path(arg) -> tuple[int, int, Path]:
95+
_case, path, inventory = arg
96+
json_path: Path = (Path(path) / inventory).with_suffix(".json")
97+
if not json_path.exists():
98+
msg = f"Cannot find file {json_path}"
99+
raise FindPathError(msg)
100+
try:
101+
material_id = int(inventory[_LEN_INVENTORY:])
102+
case_str = json_path.parent.parts[-1]
103+
case_id = int(case_str[_LEN_CASE:])
104+
except (ValueError, IndexError) as x:
105+
msg = f"Cannot define material_id and case_id from {json_path}"
106+
raise FindPathError(msg) from x
107+
if case_id != _case:
108+
msg = f"Contradicting values of case_id in case path and database: {case_id} != {_case}"
109+
raise FindPathError(msg)
110+
return material_id, case_id, json_path
111+
112+
with futures.ThreadPoolExecutor(max_workers=threads) as executor:
113+
mcp_futures = [
114+
executor.submit(_find_path, arg)
115+
for arg in (
116+
(task_case[0], task_case[1], task)
117+
for task_case in task_list
118+
for task in task_case[2].split(",")
119+
if task.startswith("inventory-")
120+
)
121+
]
122+
123+
mips = [x.result() for x in futures.as_completed(mcp_futures)]
124+
mips.sort(key=lambda x: x[0:2]) # sort by material_id, case_id
125+
126+
def _load_json(arg) -> None:
127+
collector, material_id, case_id, json_path = arg
128+
collector.append(from_json(json_path.read_text(encoding="utf8")), material_id, case_id)
129+
130+
with futures.ThreadPoolExecutor(max_workers=threads) as executor:
131+
executor.map(_load_json, ((collector, *mip) for mip in mips))
132+
87133
88134
collected = collector.get_result()
89135

noxfile.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ def isort(s: Session) -> None:
190190
"adhoc/*.py",
191191
]
192192
cwd = Path.cwd()
193-
files_to_process: list[str] = [
194-
str(x) for x in sum((list(cwd.glob(p)) for p in search_patterns), [])
195-
]
193+
files_to_process: list[str] = [str(x) for p in search_patterns for x in cwd.glob(p)]
196194
if files_to_process:
197195
s.run(
198196
"poetry",

0 commit comments

Comments
 (0)