Skip to content

Commit 0cb2167

Browse files
committed
Remove timeouts internal file
1 parent f155fb0 commit 0cb2167

File tree

5 files changed

+0
-558
lines changed

5 files changed

+0
-558
lines changed

.internal/pre_commit_tools/clean_timeouts.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

.internal/pre_commit_tools/notebook_pre_commit_collection.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
import yaml
1212

1313
PROJECT_ROOT = Path(subprocess.getoutput("git rev-parse --show-toplevel")) # noqa: S605
14-
TIMEOUTS_FILE = PROJECT_ROOT / "tests" / "resources" / "timeouts.yaml"
15-
16-
DEFAULT_TIMEOUT_SECONDS: float = 20
17-
18-
ENFORCE_TIMEOUTS: bool = False
1914

2015

2116
def main(full_file_paths: Iterable[str]) -> bool:
@@ -41,27 +36,6 @@ def is_valid_notebook(file_path: str, automatically_add_timeout: bool = True) ->
4136
f" for example, you may change '{file_path}' to '{file_path.replace(' ', '_')}'."
4237
)
4338

44-
if (
45-
ENFORCE_TIMEOUTS
46-
and not _is_file_in_timeouts(file_name)
47-
and should_notebook_be_tested(file_path)
48-
):
49-
if automatically_add_timeout:
50-
_add_file_to_timeouts(file_name)
51-
errors.append(
52-
"A new notebook was detected.\n"
53-
f" Automatically adding a timeout entry {{{file_name} : {DEFAULT_TIMEOUT_SECONDS}}}.\n"
54-
f" Please make sure to add the changes done to '{TIMEOUTS_FILE}'"
55-
)
56-
else:
57-
errors.append(
58-
"A new notebook was detected.\n"
59-
" However, a coresponding entry in the timeouts file is missing.\n"
60-
f" Please add an entry. You may add '{{{file_name} : {DEFAULT_TIMEOUT_SECONDS}}}'\n"
61-
f" to {TIMEOUTS_FILE}\n"
62-
" Alternatively, you may install pre-commit. It will automatically add a timeout entry in the next time you run 'git commit'."
63-
)
64-
6539
if errors:
6640
spacing = "\n\t" # f-string cannot include backslash
6741
print(f"File `{file_path}` has error(s):{spacing}{spacing.join(errors)}")
@@ -81,23 +55,6 @@ def _does_contain_space_in_file_name(file_name: str) -> bool:
8155
return " " in file_name
8256

8357

84-
def _is_file_in_timeouts(file_name: str) -> bool:
85-
with TIMEOUTS_FILE.open("r") as f:
86-
timeouts = yaml.safe_load(f)
87-
88-
return file_name in timeouts
89-
90-
91-
def _add_file_to_timeouts(file_name: str) -> None:
92-
with TIMEOUTS_FILE.open("r") as f:
93-
timeouts = yaml.safe_load(f)
94-
95-
timeouts[file_name] = DEFAULT_TIMEOUT_SECONDS
96-
97-
with TIMEOUTS_FILE.open("w") as f:
98-
yaml.dump(timeouts, f, sort_keys=True)
99-
100-
10158
def validate_unique_names() -> bool:
10259
all_files = PROJECT_ROOT.rglob("*.ipynb")
10360
base_names = [

.internal/pre_commit_tools/qmod_pre_commit_collection.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
import yaml
1212

1313
PROJECT_ROOT = Path(subprocess.getoutput("git rev-parse --show-toplevel")) # noqa: S605
14-
TIMEOUTS_FILE = PROJECT_ROOT / "tests" / "resources" / "timeouts.yaml"
15-
16-
DEFAULT_TIMEOUT_SECONDS: float = 10
17-
18-
ENFORCE_TIMEOUTS: bool = False
1914

2015

2116
def main(full_file_paths: Iterable[str]) -> bool:
@@ -45,27 +40,6 @@ def is_valid_qmod(
4540
f" for example, you may change '{file_path}' to '{file_path.replace(' ', '_')}'."
4641
)
4742

48-
if (
49-
ENFORCE_TIMEOUTS
50-
and not _is_file_in_timeouts(file_name)
51-
and should_notebook_be_tested(file_path)
52-
):
53-
if automatically_add_timeout:
54-
_add_file_to_timeouts(file_name)
55-
errors.append(
56-
"A new qmod was detected.\n"
57-
f" Automatically adding a timeout entry {{{file_name} : {DEFAULT_TIMEOUT_SECONDS}}}.\n"
58-
f" Please make sure to add the changes done to '{TIMEOUTS_FILE}'"
59-
)
60-
else:
61-
errors.append(
62-
"A new qmod was detected.\n"
63-
" However, a coresponding entry in the timeouts file is missing.\n"
64-
f" Please add an entry. You may add '{{{file_name} : {DEFAULT_TIMEOUT_SECONDS}}}'\n"
65-
f" to {TIMEOUTS_FILE}\n"
66-
" Alternatively, you may install pre-commit. It will automatically add a timeout entry in the next time you run 'git commit'."
67-
)
68-
6943
spacing = "\n\t" # f-string cannot include backslash
7044
errors_combined_message = (
7145
f"File `{file_path}` has error(s):{spacing}{spacing.join(errors)}"
@@ -92,23 +66,6 @@ def _does_contain_space_in_file_name(file_name: str) -> bool:
9266
return " " in file_name
9367

9468

95-
def _is_file_in_timeouts(file_name: str) -> bool:
96-
with TIMEOUTS_FILE.open("r") as f:
97-
timeouts = yaml.safe_load(f)
98-
99-
return file_name in timeouts
100-
101-
102-
def _add_file_to_timeouts(file_name: str) -> None:
103-
with TIMEOUTS_FILE.open("r") as f:
104-
timeouts = yaml.safe_load(f)
105-
106-
timeouts[file_name] = DEFAULT_TIMEOUT_SECONDS
107-
108-
with TIMEOUTS_FILE.open("w") as f:
109-
yaml.dump(timeouts, f, sort_keys=True)
110-
111-
11269
def validate_unique_names() -> bool:
11370
all_files: Iterable[Path] = PROJECT_ROOT.rglob("*.qmod")
11471
# exclude `functions/`

.pre-commit-config.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ repos:
8282
additional_dependencies:
8383
- "pyyaml==6.0"
8484
require_serial: true
85-
# - id: clean-demo-timeouts
86-
# name: Clean demo timeouts
87-
# description: Remove unexisting entries and verify unique keys
88-
# entry: .internal/pre_commit_tools/clean_timeouts.py
89-
# language: python
90-
# files: \.(qmod|ipynb|yaml)$
91-
# additional_dependencies:
92-
# - "pyyaml==6.0"
93-
# require_serial: true
9485
- id: validate-metadata-file
9586
name: Validate Metadata file
9687
description: Add file if non existant and validate value otherwise

0 commit comments

Comments
 (0)