From 532c4fd885454ee89fcbd678bdade3acabc1a62d Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 19 Nov 2024 17:43:04 +0100 Subject: [PATCH] RecordingStream.to_native(recording) -> recording.to_native() --- rerun_notebook/package-lock.json | 2 +- rerun_py/rerun_sdk/rerun/_log.py | 8 +++--- rerun_py/rerun_sdk/rerun/_send_columns.py | 2 +- rerun_py/rerun_sdk/rerun/memory.py | 2 +- rerun_py/rerun_sdk/rerun/recording_stream.py | 14 +++++----- rerun_py/rerun_sdk/rerun/sinks.py | 14 +++++----- rerun_py/rerun_sdk/rerun/time.py | 10 +++---- scripts/lint.py | 28 ++++++++++++-------- 8 files changed, 42 insertions(+), 38 deletions(-) diff --git a/rerun_notebook/package-lock.json b/rerun_notebook/package-lock.json index fb15f46c36d8..98ffe5ec105e 100644 --- a/rerun_notebook/package-lock.json +++ b/rerun_notebook/package-lock.json @@ -17,7 +17,7 @@ }, "../rerun_js/web-viewer": { "name": "@rerun-io/web-viewer", - "version": "0.20.0-alpha.1+dev", + "version": "0.20.1-alpha.2", "license": "MIT", "devDependencies": { "dts-buddy": "^0.3.0", diff --git a/rerun_py/rerun_sdk/rerun/_log.py b/rerun_py/rerun_sdk/rerun/_log.py index 9e8be9343c7d..540e9567aa51 100644 --- a/rerun_py/rerun_sdk/rerun/_log.py +++ b/rerun_py/rerun_sdk/rerun/_log.py @@ -254,7 +254,7 @@ def log_components( static = True # Convert to a native recording - recording = RecordingStream.to_native(recording) + recording = recording.to_native() instanced: dict[str, pa.Array] = {} @@ -294,7 +294,7 @@ def log_components( entity_path, components=instanced, static_=static, - recording=RecordingStream.to_native(recording), + recording=recording.to_native(), ) @@ -358,7 +358,7 @@ def log_file_from_path( Path(file_path), entity_path_prefix=entity_path_prefix, static_=static, - recording=RecordingStream.to_native(recording), + recording=recording.to_native(), ) @@ -419,7 +419,7 @@ def log_file_from_contents( file_contents, entity_path_prefix=entity_path_prefix, static_=static, - recording=RecordingStream.to_native(recording), + recording=recording.to_native(), ) diff --git a/rerun_py/rerun_sdk/rerun/_send_columns.py b/rerun_py/rerun_sdk/rerun/_send_columns.py index a8a1b2e1a347..1cf8726060e6 100644 --- a/rerun_py/rerun_sdk/rerun/_send_columns.py +++ b/rerun_py/rerun_sdk/rerun/_send_columns.py @@ -252,5 +252,5 @@ def send_columns( entity_path, timelines={t.timeline_name(): t.as_arrow_array() for t in times}, components=components_args, - recording=RecordingStream.to_native(recording), + recording=recording.to_native(), ) diff --git a/rerun_py/rerun_sdk/rerun/memory.py b/rerun_py/rerun_sdk/rerun/memory.py index 1048caffcf42..16eec0e8ad2c 100644 --- a/rerun_py/rerun_sdk/rerun/memory.py +++ b/rerun_py/rerun_sdk/rerun/memory.py @@ -28,7 +28,7 @@ def memory_recording(recording: RecordingStream | None = None) -> MemoryRecordin """ - return MemoryRecording(bindings.memory_recording(recording=RecordingStream.to_native(recording))) + return MemoryRecording(bindings.memory_recording(recording=recording.to_native())) class MemoryRecording: diff --git a/rerun_py/rerun_sdk/rerun/recording_stream.py b/rerun_py/rerun_sdk/rerun/recording_stream.py index 7aebeb8001d6..4522e16d7642 100644 --- a/rerun_py/rerun_sdk/rerun/recording_stream.py +++ b/rerun_py/rerun_sdk/rerun/recording_stream.py @@ -307,7 +307,7 @@ def binary_stream(recording: RecordingStream | None = None) -> BinaryStream: An object that can be used to flush or read the data. """ - return BinaryStream(bindings.binary_stream(recording=RecordingStream.to_native(recording))) + return BinaryStream(bindings.binary_stream(recording=recording.to_native())) class BinaryStream: @@ -380,7 +380,7 @@ def is_enabled( This can be controlled with the environment variable `RERUN` (e.g. `RERUN=on` or `RERUN=off`). """ - return bindings.is_enabled(recording=RecordingStream.to_native(recording)) # type: ignore[no-any-return] + return bindings.is_enabled(recording=recording.to_native()) # type: ignore[no-any-return] def get_application_id( @@ -402,7 +402,7 @@ def get_application_id( The application ID that this recording is associated with. """ - app_id = bindings.get_application_id(recording=RecordingStream.to_native(recording)) + app_id = bindings.get_application_id(recording=recording.to_native()) return str(app_id) if app_id is not None else None @@ -434,7 +434,7 @@ def get_recording_id( The recording ID that this recording is logging to. """ - rec_id = bindings.get_recording_id(recording=RecordingStream.to_native(recording)) + rec_id = bindings.get_recording_id(recording=recording.to_native()) return str(rec_id) if rec_id is not None else None @@ -467,7 +467,7 @@ def get_data_recording( The most appropriate recording to log data to, in the current context, if any. """ - result = bindings.get_data_recording(recording=RecordingStream.to_native(recording)) + result = bindings.get_data_recording(recording=recording.to_native()) return RecordingStream(result) if result is not None else None @@ -495,7 +495,7 @@ def set_global_data_recording(recording: RecordingStream) -> RecordingStream | N The newly active global recording. """ - result = bindings.set_global_data_recording(RecordingStream.to_native(recording)) + result = bindings.set_global_data_recording(recording.to_native()) return RecordingStream(result) if result is not None else None @@ -523,7 +523,7 @@ def set_thread_local_data_recording(recording: RecordingStream) -> RecordingStre The newly active thread-local recording. """ - result = bindings.set_thread_local_data_recording(recording=RecordingStream.to_native(recording)) + result = bindings.set_thread_local_data_recording(recording=recording.to_native()) return RecordingStream(result) if result is not None else None diff --git a/rerun_py/rerun_sdk/rerun/sinks.py b/rerun_py/rerun_sdk/rerun/sinks.py index 2e713c9156bb..df223da6d4be 100644 --- a/rerun_py/rerun_sdk/rerun/sinks.py +++ b/rerun_py/rerun_sdk/rerun/sinks.py @@ -131,7 +131,7 @@ def connect_tcp( addr=addr, flush_timeout_sec=flush_timeout_sec, default_blueprint=blueprint_storage, - recording=RecordingStream.to_native(recording), + recording=recording.to_native(), ) @@ -180,7 +180,7 @@ def save( application_id=application_id, blueprint=default_blueprint ).storage - bindings.save(path=str(path), default_blueprint=blueprint_storage, recording=RecordingStream.to_native(recording)) + bindings.save(path=str(path), default_blueprint=blueprint_storage, recording=recording.to_native()) def stdout(default_blueprint: BlueprintLike | None = None, recording: RecordingStream | None = None) -> None: @@ -225,7 +225,7 @@ def stdout(default_blueprint: BlueprintLike | None = None, recording: RecordingS application_id=application_id, blueprint=default_blueprint ).storage - bindings.stdout(default_blueprint=blueprint_storage, recording=RecordingStream.to_native(recording)) + bindings.stdout(default_blueprint=blueprint_storage, recording=recording.to_native()) def disconnect(recording: RecordingStream | None = None) -> None: @@ -244,7 +244,7 @@ def disconnect(recording: RecordingStream | None = None) -> None: """ - bindings.disconnect(recording=RecordingStream.to_native(recording)) + bindings.disconnect(recording=recording.to_native()) @deprecated( @@ -382,7 +382,7 @@ def serve_web( ws_port, server_memory_limit=server_memory_limit, default_blueprint=blueprint_storage, - recording=RecordingStream.to_native(recording), + recording=recording.to_native(), ) @@ -423,9 +423,7 @@ def send_blueprint( blueprint_storage = create_in_memory_blueprint(application_id=application_id, blueprint=blueprint).storage - bindings.send_blueprint( - blueprint_storage, make_active, make_default, recording=RecordingStream.to_native(recording) - ) + bindings.send_blueprint(blueprint_storage, make_active, make_default, recording=recording.to_native()) def spawn( diff --git a/rerun_py/rerun_sdk/rerun/time.py b/rerun_py/rerun_sdk/rerun/time.py index 12cad17b805c..d1cc52e8db50 100644 --- a/rerun_py/rerun_sdk/rerun/time.py +++ b/rerun_py/rerun_sdk/rerun/time.py @@ -32,7 +32,7 @@ def set_time_sequence(timeline: str, sequence: int, recording: RecordingStream | See also: [`rerun.init`][], [`rerun.set_global_data_recording`][]. """ - bindings.set_time_sequence(timeline, sequence, recording=RecordingStream.to_native(recording)) + bindings.set_time_sequence(timeline, sequence, recording=recording.to_native()) def set_time_seconds(timeline: str, seconds: float, recording: RecordingStream | None = None) -> None: @@ -68,7 +68,7 @@ def set_time_seconds(timeline: str, seconds: float, recording: RecordingStream | """ - bindings.set_time_seconds(timeline, seconds, recording=RecordingStream.to_native(recording)) + bindings.set_time_seconds(timeline, seconds, recording=recording.to_native()) def set_time_nanos(timeline: str, nanos: int, recording: RecordingStream | None = None) -> None: @@ -104,7 +104,7 @@ def set_time_nanos(timeline: str, nanos: int, recording: RecordingStream | None """ - bindings.set_time_nanos(timeline, nanos, recording=RecordingStream.to_native(recording)) + bindings.set_time_nanos(timeline, nanos, recording=recording.to_native()) def disable_timeline(timeline: str, recording: RecordingStream | None = None) -> None: @@ -122,7 +122,7 @@ def disable_timeline(timeline: str, recording: RecordingStream | None = None) -> """ - bindings.disable_timeline(timeline, recording=RecordingStream.to_native(recording)) + bindings.disable_timeline(timeline, recording=recording.to_native()) def reset_time(recording: RecordingStream | None = None) -> None: @@ -143,4 +143,4 @@ def reset_time(recording: RecordingStream | None = None) -> None: """ - bindings.reset_time(recording=RecordingStream.to_native(recording)) + bindings.reset_time(recording=recording.to_native()) diff --git a/scripts/lint.py b/scripts/lint.py index 13cc8a995885..ea87b7e0c1ea 100755 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -173,8 +173,13 @@ def lint_line( if re.search(r"\b3d\b", line): return "we prefer '3D' over '3d'" - if "recording=rec" in line: - return "you must cast the RecordingStream first: `recording=RecordingStream.to_native(recording)" + if ( + "recording=rec" in line + and "recording=rec.to_native()" not in line + and "recording=recording.to_native()" not in line + and "rr.notebook_show" not in line + ): + return "you must cast the RecordingStream first: `recording=recording.to_native()" if "FIXME" in line: return "we prefer TODO over FIXME" @@ -1232,24 +1237,25 @@ def main() -> None: "./rerun_cpp/docs/html", "./rerun_cpp/src/rerun/c/arrow_c_data_interface.h", # Not our code "./rerun_cpp/src/rerun/third_party/cxxopts.hpp", # vendored + "./rerun_js/node_modules", + "./rerun_js/web-viewer-react/node_modules", + "./rerun_js/web-viewer/index.js", + "./rerun_js/web-viewer/inlined.js", + "./rerun_js/web-viewer/node_modules", + "./rerun_js/web-viewer/re_viewer.js", + "./rerun_js/web-viewer/re_viewer_bg.js", # auto-generated by wasm_bindgen + "./rerun_notebook/node_modules", + "./rerun_notebook/src/rerun_notebook/static", "./rerun_py/.pytest_cache/", "./rerun_py/site/", # is in `.gitignore` which this script doesn't fully respect "./run_wasm/README.md", # Has a "2d" lowercase example in a code snippet "./scripts/lint.py", # we contain all the patterns we are linting against "./scripts/zombie_todos.py", + "./tests/python/gil_stress/main.py", "./tests/python/release_checklist/main.py", "./web_viewer/re_viewer.js", # auto-generated by wasm_bindgen # JS dependencies: - "./rerun_notebook/node_modules", - "./rerun_js/node_modules", # JS files generated during build: - "./rerun_notebook/src/rerun_notebook/static", - "./rerun_js/web-viewer-react/node_modules", - "./rerun_js/web-viewer/index.js", - "./rerun_js/web-viewer/inlined.js", - "./rerun_js/web-viewer/node_modules", - "./rerun_js/web-viewer/re_viewer_bg.js", # auto-generated by wasm_bindgen - "./rerun_js/web-viewer/re_viewer.js", ) should_ignore = parse_gitignore(".gitignore") # TODO(#6730): parse all .gitignore files, not just top-level