From ee51fe8b2057bd2c390542636e1e60b005775538 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:56:28 +0200 Subject: [PATCH] Remove aspect ratio check from `upload_image.py` (#5806) ### What That check dates back from when we used the screenshot as thumbnail, so we needed it to have some sensible aspect ratio. That's history now, and bypassing this check every time is most annoying. ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using newly built examples: [rerun.io/viewer](https://rerun.io/viewer/pr/5806) * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5806?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5806?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5806) - [Docs preview](https://rerun.io/preview/3382c7c3964426d42115a8b9e3476c313145a153/docs) - [Examples preview](https://rerun.io/preview/3382c7c3964426d42115a8b9e3476c313145a153/examples) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) --- scripts/upload_image.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/scripts/upload_image.py b/scripts/upload_image.py index 7236a25744c4..ec357db78138 100755 --- a/scripts/upload_image.py +++ b/scripts/upload_image.py @@ -72,8 +72,6 @@ 1200, ] -ASPECT_RATIO_RANGE = (1.6, 1.8) - def build_image_stack(image: Image) -> list[tuple[int | None, Image]]: image_stack: list[tuple[int | None, Image]] = [(None, image)] @@ -120,32 +118,14 @@ def image_from_clipboard() -> Image: class Uploader: - def __init__(self, auto_accept: bool): + def __init__(self): gcs = storage.Client("rerun-open") self.bucket = gcs.bucket("rerun-static-img") - self.auto_accept = auto_accept def _check_aspect_ratio(self, image: Path | Image) -> None: if isinstance(image, Path): image = PIL.Image.open(image) - aspect_ratio = image.width / image.height - aspect_ok = ASPECT_RATIO_RANGE[0] < aspect_ratio < ASPECT_RATIO_RANGE[1] - - if not aspect_ok and not self.auto_accept: - logging.warning( - f"Aspect ratio is {aspect_ratio:.2f} but should be between {ASPECT_RATIO_RANGE[0]} and " - f"{ASPECT_RATIO_RANGE[1]}." - ) - # do not pass prompt to input as this goes to stdout - print( - "The image aspect ratio is outside the range recommended for example screenshots. Continue? [y/N] ", - end="", - file=sys.stderr, - ) - if input().lower() != "y": - sys.exit(1) - def upload_file(self, path: Path) -> str: """ Upload a single file to Google Cloud. @@ -355,7 +335,7 @@ def download_file(url: str, path: Path) -> None: def run(args: argparse.Namespace) -> None: """Run the script based on the provided args.""" try: - uploader = Uploader(args.auto_accept) + uploader = Uploader() if args.single: if args.path is None: @@ -415,7 +395,6 @@ def main() -> None: "--single", action="store_true", help="Upload a single image instead of creating a multi-resolution stack." ) parser.add_argument("--name", type=str, help="Image name (required when uploading from clipboard).") - parser.add_argument("--auto-accept", action="store_true", help="Auto-accept the aspect ratio confirmation prompt") parser.add_argument("--debug", action="store_true", help="Enable debug logging.") args = parser.parse_args()