Copilot commented on code in PR #53577:
URL: https://github.com/apache/airflow/pull/53577#discussion_r2243765135
##########
scripts/ci/pre_commit/compile_provider_assets.py:
##########
@@ -94,10 +104,10 @@ def compile_assets(www_directory: Path):
sys.exit(result.returncode)
subprocess.check_call(["yarn", "run", "build"],
cwd=os.fspath(www_directory), env=env)
new_hash = get_directory_hash(www_directory,
skip_path_regexps=SKIP_PATH_REGEXPS)
- FAB_PROVIDER_WWW_HASH_FILE.write_text(new_hash + "\n")
+ provider_paths["hash"].write_text(new_hash + "\n")
print(f"Assets compiled successfully. New hash: {new_hash}")
if __name__ == "__main__":
Review Comment:
The script lacks proper error handling for missing command line arguments.
If no provider argument is provided, this will raise an IndexError with an
unclear message. Consider adding validation with a helpful error message.
```suggestion
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Error: Missing required provider argument.")
print("Usage: ./compile_provider_assets.py <provider_name>")
sys.exit(1)
```
##########
scripts/ci/pre_commit/compile_provider_assets.py:
##########
@@ -94,10 +104,10 @@ def compile_assets(www_directory: Path):
sys.exit(result.returncode)
subprocess.check_call(["yarn", "run", "build"],
cwd=os.fspath(www_directory), env=env)
new_hash = get_directory_hash(www_directory,
skip_path_regexps=SKIP_PATH_REGEXPS)
- FAB_PROVIDER_WWW_HASH_FILE.write_text(new_hash + "\n")
+ provider_paths["hash"].write_text(new_hash + "\n")
print(f"Assets compiled successfully. New hash: {new_hash}")
if __name__ == "__main__":
- # Compile assets for fab provider
- compile_assets(FAB_PROVIDER_WWW_PATH)
+ provider = sys.argv[1]
+ compile_assets(provider)
Review Comment:
[nitpick] Consider using argparse for better command line argument handling
instead of directly accessing sys.argv[1]. This would provide better error
messages and help text for users.
```suggestion
parser = argparse.ArgumentParser(
description="Compile provider assets for the specified provider."
)
parser.add_argument(
"provider",
type=str,
help="The name of the provider whose assets should be compiled.",
)
args = parser.parse_args()
compile_assets(args.provider)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]