-
Notifications
You must be signed in to change notification settings - Fork 175
Update report upload logic #972
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
Update report upload logic #972
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @abohoss !
Could you please address the nits below?
I will create a PR to run experiment for your changes : )
report/upload_report.py
Outdated
default_dir = f"{os.getenv('USER')}-{datetime.now().strftime('%Y-%m-%d')}" | ||
parser.error(f"This script needs to take gcloud Bucket directory as the second argument. Consider using: {default_dir}") | ||
if not args.model: | ||
parser.error("This script needs to take LLM as the third argument.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
results_dir
(and the other parameters) are positional and therefore automatically required by argparse, the code inside the if not args.results_dir:
block will not be executed if results_dir
is missing. You can rely on argparse's built-in error handling for missing arguments instead of adding these checks manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, I would prefer placing these arg parsing and handling in an individual function.
report/upload_report.py
Outdated
) | ||
self.logger = logging.getLogger(__name__) | ||
|
||
def run_command(self, command: list) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could you please make the functions that are only used in the class private? (e.g., _func
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the following function private in the PR : _generate_training_data
, _generate_report
, _run_command
,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!This helps the linter to report unused functions so that we can remove zombie code.
report/upload_report.py
Outdated
self.benchmark_set = benchmark_set | ||
self.model = model | ||
self.results_report_dir = Path('results-report') | ||
self.bucket_base_path = "gs://oss-fuzz-gcb-experiment-run-logs/Result-reports" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use '
for consistency in python code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it in all code except this line: self.logger.error(f"Command failed: {' '.join(command)}")
,because using single quotes here can cause a syntax issue because the inner quotes clash with the outer quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
self.logger.error(f'Command failed: {" ".join(command)}')
The main idea is, using '
by default and "
only when necessary.
Hi @DonggeLiu , |
…ss/oss-fuzz-gen into update_report_upload_logic
…ss/oss-fuzz-gen into update_report_upload_logic
Ah I see you already pushed the new changes here, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again, @abohoss!
Some final nits:
report/docker_run.py
Outdated
gcs_report_dir = f"{args.sub_dir}/{experiment_name}" | ||
|
||
# Trends report use a similarly named path. | ||
gcs_trend_report_path = f"{args.sub_dir}/{experiment_name}.json" | ||
|
||
# Generate a report and upload it to GCS | ||
report_process = subprocess.Popen([ | ||
"bash", "report/upload_report.sh", local_results_dir, gcs_report_dir, | ||
"python3", "report/upload_report.py", local_results_dir, gcs_report_dir, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I missed this last time:
Could you please change this python3
to be python_path
just like in
oss-fuzz-gen/report/docker_run.py
Line 380 in 9771601
python_path, "run_all_experiments.py", "--benchmarks-directory", |
This is to ensure the correct python
is used in the docker container.
report/upload_report.py
Outdated
self.logger.info('Final report uploaded.') | ||
|
||
|
||
def parse_args(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add return type.
def parse_args() -> argparse.Namespace:
report/upload_report.py
Outdated
) | ||
self.logger = logging.getLogger(__name__) | ||
|
||
def run_command(self, command: list) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!This helps the linter to report unused functions so that we can remove zombie code.
report/upload_report.py
Outdated
self.benchmark_set = benchmark_set | ||
self.model = model | ||
self.results_report_dir = Path('results-report') | ||
self.bucket_base_path = "gs://oss-fuzz-gcb-experiment-run-logs/Result-reports" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
self.logger.error(f'Command failed: {" ".join(command)}')
The main idea is, using '
by default and "
only when necessary.
…ss/oss-fuzz-gen into update_report_upload_logic
Hi @DonggeLiu , |
Thanks for addressing this so promptly! |
As mentioned in #971 , I created a `upload_report.py` file where this python version offers several improvements over the bash script including: 1. Better Structure: - Object-oriented design with a clear separation of concerns - Methods are modular and reusable 2. Improved Error Handling: - Comprehensive logging - Proper exception handling - Command execution status checking 3. Enhanced Features: - Argument parsing with helpful error messages - Better file path handling using Path objects 4. Better Maintainability: - Logical grouping of related functionality - Easier to extend and modify --------- Co-authored-by: Dongge Liu <[email protected]>
Ops The linter CI reported some issues. This script will help you identify the error locally pushing : ) |
You're welcome! |
Hi @DonggeLiu! |
As mentioned in #971 , I created a
upload_report.py
file where this python version offers several improvements over the bash script including: