-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check
examples/python/requirements.txt
in CI (#2063)
* add `check_requirements.py` * add `check_requirements.py` to CI checks * add missing requirements sorted alphabetically * check if requirements are sorted also intentionally submit incorrect `requirements.txt` so that CI fails * fix `examples/python/requirements.txt`
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
-r api_demo/requirements.txt | ||
-r arkitscenes/requirements.txt | ||
-r car/requirements.txt | ||
-r clock/requirements.txt | ||
-r colmap/requirements.txt | ||
-r deep_sdf/requirements.txt | ||
-r dicom/requirements.txt | ||
-r dna/requirements.txt | ||
-r minimal/requirements.txt | ||
-r mp_pose/requirements.txt | ||
-r multiprocessing/requirements.txt | ||
-r multithreading/requirements.txt | ||
-r notebook/requirements.txt | ||
-r nyud/requirements.txt | ||
-r objectron/requirements.txt | ||
-r opencv_canny/requirements.txt | ||
-r plots/requirements.txt | ||
-r raw_mesh/requirements.txt | ||
-r ros/requirements.txt | ||
-r segment_anything/requirements.txt | ||
-r stable_diffusion/requirements.txt | ||
-r text_logging/requirements.txt | ||
-r tracking_hf_opencv/requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from glob import glob | ||
|
||
|
||
def main() -> None: | ||
failed = False | ||
|
||
print("Checking `examples/python/requirements.txt`...") | ||
with open("examples/python/requirements.txt") as f: | ||
lines = f.read().strip().splitlines() | ||
sorted_lines = lines.copy() | ||
sorted_lines.sort() | ||
requirements = set(lines) | ||
|
||
missing = [] | ||
for path in glob("examples/python/*/requirements.txt"): | ||
line = f"-r {os.path.relpath(path, 'examples/python')}" | ||
if line not in requirements: | ||
missing.append(line) | ||
|
||
if len(missing) != 0: | ||
print("\n`examples/python/requirements.txt` is missing the following requirements:") | ||
for line in missing: | ||
print(line) | ||
failed = True | ||
|
||
if lines != sorted_lines: | ||
print("\n`examples/python/requirements.txt` is not correctly sorted.") | ||
failed = True | ||
|
||
if failed: | ||
print("\nHere is what `examples/python/requirements.txt` should contain:") | ||
expected = glob("examples/python/*/requirements.txt") | ||
expected.sort() | ||
for path in expected: | ||
print(f"-r {os.path.relpath(path, 'examples/python')}") | ||
exit(1) | ||
else: | ||
print("All clear.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |