@@ -967,59 +967,96 @@ fn log_arrow_msg(
967
967
#[ pyfunction]
968
968
#[ pyo3( signature = (
969
969
file_path,
970
+ recording_id = None ,
971
+ entity_path_prefix = None ,
972
+ timeless = None ,
970
973
recording=None ,
971
974
) ) ]
972
975
fn log_file_from_path (
973
976
py : Python < ' _ > ,
974
977
file_path : std:: path:: PathBuf ,
978
+ recording_id : Option < String > ,
979
+ entity_path_prefix : Option < String > ,
980
+ timeless : Option < bool > ,
975
981
recording : Option < & PyRecordingStream > ,
976
982
) -> PyResult < ( ) > {
977
- let Some ( recording) = get_data_recording ( recording) else {
978
- return Ok ( ( ) ) ;
979
- } ;
980
-
981
- let Some ( recording_id) = recording. store_info ( ) . map ( |info| info. store_id . clone ( ) ) else {
982
- return Ok ( ( ) ) ;
983
- } ;
984
- let settings = rerun:: DataLoaderSettings :: recommended ( recording_id) ;
985
-
986
- recording
987
- . log_file_from_path ( & settings, file_path)
988
- . map_err ( |err| PyRuntimeError :: new_err ( err. to_string ( ) ) ) ?;
989
-
990
- py. allow_threads ( flush_garbage_queue) ;
991
-
992
- Ok ( ( ) )
983
+ log_file (
984
+ py,
985
+ file_path,
986
+ None ,
987
+ recording_id,
988
+ entity_path_prefix,
989
+ timeless,
990
+ recording,
991
+ )
993
992
}
994
993
995
994
#[ pyfunction]
996
995
#[ pyo3( signature = (
997
996
file_path,
998
997
file_contents,
998
+ recording_id = None ,
999
+ entity_path_prefix = None ,
1000
+ timeless = None ,
999
1001
recording=None ,
1000
1002
) ) ]
1001
1003
fn log_file_from_contents (
1002
1004
py : Python < ' _ > ,
1003
1005
file_path : std:: path:: PathBuf ,
1004
1006
file_contents : & [ u8 ] ,
1007
+ recording_id : Option < String > ,
1008
+ entity_path_prefix : Option < String > ,
1009
+ timeless : Option < bool > ,
1010
+ recording : Option < & PyRecordingStream > ,
1011
+ ) -> PyResult < ( ) > {
1012
+ log_file (
1013
+ py,
1014
+ file_path,
1015
+ Some ( file_contents) ,
1016
+ recording_id,
1017
+ entity_path_prefix,
1018
+ timeless,
1019
+ recording,
1020
+ )
1021
+ }
1022
+
1023
+ fn log_file (
1024
+ py : Python < ' _ > ,
1025
+ file_path : std:: path:: PathBuf ,
1026
+ file_contents : Option < & [ u8 ] > ,
1027
+ recording_id : Option < String > ,
1028
+ entity_path_prefix : Option < String > ,
1029
+ timeless : Option < bool > ,
1005
1030
recording : Option < & PyRecordingStream > ,
1006
1031
) -> PyResult < ( ) > {
1007
1032
let Some ( recording) = get_data_recording ( recording) else {
1008
1033
return Ok ( ( ) ) ;
1009
1034
} ;
1010
1035
1011
- let Some ( recording_id) = recording. store_info ( ) . map ( |info| info. store_id . clone ( ) ) else {
1036
+ let Some ( recording_id) = recording
1037
+ . store_info ( )
1038
+ . map ( |info| info. store_id . clone ( ) )
1039
+ . or ( recording_id. map ( |id| StoreId :: from_string ( StoreKind :: Recording , id) ) )
1040
+ else {
1012
1041
return Ok ( ( ) ) ;
1013
1042
} ;
1014
- let settings = rerun:: DataLoaderSettings :: recommended ( recording_id) ;
1015
1043
1016
- recording
1017
- . log_file_from_contents (
1018
- & settings,
1019
- file_path,
1020
- std:: borrow:: Cow :: Borrowed ( file_contents) ,
1021
- )
1022
- . map_err ( |err| PyRuntimeError :: new_err ( err. to_string ( ) ) ) ?;
1044
+ let settings = rerun:: DataLoaderSettings {
1045
+ store_id : recording_id,
1046
+ opened_store_id : None ,
1047
+ entity_path_prefix : entity_path_prefix. map ( Into :: into) ,
1048
+ timepoint : timeless. unwrap_or ( false ) . then ( TimePoint :: timeless) ,
1049
+ } ;
1050
+
1051
+ if let Some ( contents) = file_contents {
1052
+ recording
1053
+ . log_file_from_contents ( & settings, file_path, std:: borrow:: Cow :: Borrowed ( contents) )
1054
+ . map_err ( |err| PyRuntimeError :: new_err ( err. to_string ( ) ) ) ?;
1055
+ } else {
1056
+ recording
1057
+ . log_file_from_path ( & settings, file_path)
1058
+ . map_err ( |err| PyRuntimeError :: new_err ( err. to_string ( ) ) ) ?;
1059
+ }
1023
1060
1024
1061
py. allow_threads ( flush_garbage_queue) ;
1025
1062
0 commit comments