Copilot commented on code in PR #162:
URL: https://github.com/apache/datasketches-rust/pull/162#discussion_r3648765673
##########
tools/download_serialization_test_data.py:
##########
@@ -102,26 +88,28 @@ def main():
parser.add_argument("--all", action="store_true", help="Download all test
data")
args = parser.parse_args()
+ repository_root = Path(__file__).resolve().parents[1]
+ serialization_test_data = repository_root / "datasketches" / "tests" /
"serialization_test_data"
+ generated_targets = {
+ "cpp": serialization_test_data / "cpp_generated_files",
+ "java": serialization_test_data / "java_generated_files",
+ }
+
languages = []
if args.java or args.all:
languages.append("java")
if args.cpp or args.all:
languages.append("cpp")
if not languages:
- languages = list(OUTPUT_DIRS)
-
- repository_root = Path(__file__).resolve().parents[1]
- project_dir = repository_root / "datasketches"
+ languages = list(generated_targets)
with tempfile.TemporaryDirectory(prefix="datasketches-tck-") as temp_dir:
archive_path = Path(temp_dir) / "datasketches-tck.zip"
download_archive(archive_path)
with zipfile.ZipFile(archive_path) as archive:
for language in languages:
- extract_snapshots(archive, project_dir, language)
-
- return 0
+ extract_snapshots(archive, generated_targets[language],
language)
if __name__ == "__main__":
- sys.exit(main())
+ main()
Review Comment:
The entrypoint now calls `main()` directly instead of `sys.exit(main())`.
Using `sys.exit` ensures the script’s exit status follows `main()`’s return
value (and keeps `sys` meaningfully used), which is important when this script
is run in CI.
##########
tools/download_serialization_test_data.py:
##########
@@ -26,25 +26,19 @@
import zipfile
from pathlib import Path, PurePosixPath
-TCK_ARCHIVE_URL =
"https://github.com/apache/datasketches-tck/archive/0016a517/main.zip"
-OUTPUT_DIRS = {
- "java": "java_generated_files",
- "cpp": "cpp_generated_files",
-}
-
def download_archive(destination):
- print(f"Downloading serialization snapshots from {TCK_ARCHIVE_URL}",
flush=True)
- request = urllib.request.Request(TCK_ARCHIVE_URL)
+ archive_url =
"https://github.com/apache/datasketches-tck/archive/0016a517/main.zip"
+ print(f"Downloading serialization snapshots from {archive_url}")
Review Comment:
`print(...)` no longer flushes output. In CI/non-interactive runs Python may
buffer stdout, so the "Downloading…" message may not appear until after the
download finishes, which makes long downloads look hung. Restore `flush=True`
for this progress message.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]