-
Notifications
You must be signed in to change notification settings - Fork 0
Update ci process #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,12 +1,10 @@ | ||||||||||||||||||||||
| import argparse | ||||||||||||||||||||||
| import os | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import akida | ||||||||||||||||||||||
| from cnn2snn import convert | ||||||||||||||||||||||
| from quantizeml import load_model | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| from compute_device import compute_min_device | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def process_model(file_path): | ||||||||||||||||||||||
| try: | ||||||||||||||||||||||
| print(f"Loading model: {file_path}") | ||||||||||||||||||||||
|
|
@@ -29,8 +27,11 @@ def process_model(file_path): | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||
| parser = argparse.ArgumentParser() | ||||||||||||||||||||||
| parser.add_argument("--model", required=True, help="Path to model file (.h5 or .onnx)") | ||||||||||||||||||||||
| parser.add_argument("--models", nargs="+", required=True, | ||||||||||||||||||||||
| help="Path to model files (.h5 or .onnx)") | ||||||||||||||||||||||
| args = parser.parse_args() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| process_model(args.model) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Process each model | ||||||||||||||||||||||
| for model_file in args.models: | ||||||||||||||||||||||
| if os.path.exists(model_file): | ||||||||||||||||||||||
| process_model(model_file) | ||||||||||||||||||||||
|
Comment on lines
+36
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you are able to simplify this as :
Suggested change
To avoid to change the previous script approach |
||||||||||||||||||||||
This file contains hidden or 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,69 @@ | ||
| """Simple post-capture filter for noisy commands. | ||
| Runs a subprocess, captures stdout+stderr, and prints allowed lines to the console. | ||
| Usage: | ||
| python CI/post_filter.py -- CI/check_model.py --models $FILES | ||
| The `--` separates options to this script from the command to run. | ||
| """ | ||
| import os | ||
| import sys | ||
| import argparse | ||
| import subprocess | ||
| import re | ||
|
|
||
| def run_and_filter(cmd:str): | ||
| """Runs a subprocess, captures stdout+stderr, and prints filtred lines to the console. | ||
| Args: | ||
| cmd (str): Python command sent from GitHub action | ||
| """ | ||
| allow = re.compile(r'(Checking model:|Loading model:|✅.*needs \d+ Akida nodes)', re.IGNORECASE) | ||
| deny = re.compile( | ||
| r'(cuda|cufft|cudnn|cublas|tensorflow|xla|absl::InitializeLog|Unable to register|WARNING:|' | ||
| r'failed call to|loop_optimizer\.cc|computation_placer|computation placer|gpu_device|Created device|' | ||
| r'TF_FORCE_GPU_ALLOW_GROWTH|Overriding orig_value)' | ||
| , re.IGNORECASE) | ||
|
|
||
| # If the command is a Python script path and not executable, prefix | ||
| # with the current Python interpreter to avoid PermissionError on CI. | ||
| if isinstance(cmd, (list, tuple)) and cmd: | ||
| first = cmd[0] | ||
| if isinstance(first, str) and first.endswith('.py') and not os.access(first, os.X_OK): | ||
| cmd = [sys.executable] + list(cmd) | ||
|
|
||
| proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) | ||
|
|
||
| try: | ||
| # Read lines as they arrive and print | ||
| for raw in iter(proc.stdout.readline, ''): | ||
| if raw is None: | ||
| break | ||
| line = raw.rstrip('\n') | ||
| keep = allow.search(line) or not deny.search(line) | ||
| if keep: | ||
| print(line, flush=True) | ||
|
|
||
| proc.wait() | ||
| finally: | ||
| try: | ||
| proc.stdout.close() | ||
| except Exception: | ||
| pass | ||
|
|
||
| def main(argv=None): | ||
| p = argparse.ArgumentParser(prog='post_filter', description='Run command and filter its output') | ||
| p.add_argument('cmd', nargs=argparse.REMAINDER, help='Command to run (use -- before the command)') | ||
| args = p.parse_args(argv) | ||
|
|
||
| if not args.cmd: | ||
| print('No command provided.' | ||
| 'Use -- to separate command, e.g.: python CI/post_filter.py -- CI/check_model.py --models $FILES') | ||
| return 2 | ||
|
|
||
| # Remove leading '--' if present | ||
| cmd = args.cmd | ||
| if cmd and cmd[0] == '--': | ||
| cmd = cmd[1:] | ||
|
|
||
| run_and_filter(cmd) | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.