@@ -14,6 +14,7 @@ use icechunk::{
1414 config:: Credentials ,
1515 format:: {
1616 SnapshotId ,
17+ format_constants:: SpecVersionBin ,
1718 repo_info:: UpdateType ,
1819 snapshot:: { ManifestFileInfo , SnapshotInfo , SnapshotProperties } ,
1920 transaction_log:: Diff ,
@@ -788,13 +789,14 @@ impl PyRepository {
788789/// python threads can make progress in the case of an actual block
789790impl PyRepository {
790791 #[ classmethod]
791- #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None ) ) ]
792+ #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None , spec_version = None ) ) ]
792793 fn create (
793794 _cls : & Bound < ' _ , PyType > ,
794795 py : Python < ' _ > ,
795796 storage : PyStorage ,
796797 config : Option < & PyRepositoryConfig > ,
797798 authorize_virtual_chunk_access : Option < HashMap < String , Option < PyCredentials > > > ,
799+ spec_version : Option < u8 > ,
798800 ) -> PyResult < Self > {
799801 // This function calls block_on, so we need to allow other thread python to make progress
800802 py. detach ( move || {
@@ -803,10 +805,17 @@ impl PyRepository {
803805 let config = config
804806 . map ( |c| c. try_into ( ) . map_err ( PyValueError :: new_err) )
805807 . transpose ( ) ?;
808+ let version = match spec_version {
809+ Some ( n) => Some (
810+ SpecVersionBin :: try_from ( n) . map_err ( PyValueError :: new_err) ?,
811+ ) ,
812+ None => None ,
813+ } ;
806814 Repository :: create (
807815 config,
808816 storage. 0 ,
809817 map_credentials ( authorize_virtual_chunk_access) ,
818+ version,
810819 )
811820 . await
812821 . map_err ( PyIcechunkStoreError :: RepositoryError )
@@ -817,23 +826,34 @@ impl PyRepository {
817826 }
818827
819828 #[ classmethod]
820- #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None ) ) ]
829+ #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None , spec_version = None ) ) ]
821830 fn create_async < ' py > (
822831 _cls : & Bound < ' py , PyType > ,
823832 py : Python < ' py > ,
824833 storage : PyStorage ,
825834 config : Option < & PyRepositoryConfig > ,
826835 authorize_virtual_chunk_access : Option < HashMap < String , Option < PyCredentials > > > ,
836+ spec_version : Option < u8 > ,
827837 ) -> PyResult < Bound < ' py , PyAny > > {
828838 let config =
829839 config. map ( |c| c. try_into ( ) . map_err ( PyValueError :: new_err) ) . transpose ( ) ?;
830840 let authorize_virtual_chunk_access =
831841 map_credentials ( authorize_virtual_chunk_access) ;
832842 pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
833- let repository =
834- Repository :: create ( config, storage. 0 , authorize_virtual_chunk_access)
835- . await
836- . map_err ( PyIcechunkStoreError :: RepositoryError ) ?;
843+ let version = match spec_version {
844+ Some ( n) => {
845+ Some ( SpecVersionBin :: try_from ( n) . map_err ( PyValueError :: new_err) ?)
846+ }
847+ None => None ,
848+ } ;
849+ let repository = Repository :: create (
850+ config,
851+ storage. 0 ,
852+ authorize_virtual_chunk_access,
853+ version,
854+ )
855+ . await
856+ . map_err ( PyIcechunkStoreError :: RepositoryError ) ?;
837857
838858 Ok ( Self ( Arc :: new ( RwLock :: new ( repository) ) ) )
839859 } )
@@ -891,13 +911,14 @@ impl PyRepository {
891911 }
892912
893913 #[ classmethod]
894- #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None ) ) ]
914+ #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None , create_version = None ) ) ]
895915 fn open_or_create (
896916 _cls : & Bound < ' _ , PyType > ,
897917 py : Python < ' _ > ,
898918 storage : PyStorage ,
899919 config : Option < & PyRepositoryConfig > ,
900920 authorize_virtual_chunk_access : Option < HashMap < String , Option < PyCredentials > > > ,
921+ create_version : Option < u8 > ,
901922 ) -> PyResult < Self > {
902923 // This function calls block_on, so we need to allow other thread python to make progress
903924 py. detach ( move || {
@@ -906,11 +927,18 @@ impl PyRepository {
906927 let config = config
907928 . map ( |c| c. try_into ( ) . map_err ( PyValueError :: new_err) )
908929 . transpose ( ) ?;
930+ let version = match create_version {
931+ Some ( n) => Some (
932+ SpecVersionBin :: try_from ( n) . map_err ( PyValueError :: new_err) ?,
933+ ) ,
934+ None => None ,
935+ } ;
909936 Ok :: < _ , PyErr > (
910937 Repository :: open_or_create (
911938 config,
912939 storage. 0 ,
913940 map_credentials ( authorize_virtual_chunk_access) ,
941+ version,
914942 )
915943 . await
916944 . map_err ( PyIcechunkStoreError :: RepositoryError ) ?,
@@ -922,23 +950,31 @@ impl PyRepository {
922950 }
923951
924952 #[ classmethod]
925- #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None ) ) ]
953+ #[ pyo3( signature = ( storage, * , config = None , authorize_virtual_chunk_access = None , create_version = None ) ) ]
926954 fn open_or_create_async < ' py > (
927955 _cls : & Bound < ' py , PyType > ,
928956 py : Python < ' py > ,
929957 storage : PyStorage ,
930958 config : Option < & PyRepositoryConfig > ,
931959 authorize_virtual_chunk_access : Option < HashMap < String , Option < PyCredentials > > > ,
960+ create_version : Option < u8 > ,
932961 ) -> PyResult < Bound < ' py , PyAny > > {
933962 let config =
934963 config. map ( |c| c. try_into ( ) . map_err ( PyValueError :: new_err) ) . transpose ( ) ?;
935964 let authorize_virtual_chunk_access =
936965 map_credentials ( authorize_virtual_chunk_access) ;
937966 pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
967+ let version = match create_version {
968+ Some ( n) => {
969+ Some ( SpecVersionBin :: try_from ( n) . map_err ( PyValueError :: new_err) ?)
970+ }
971+ None => None ,
972+ } ;
938973 let repository = Repository :: open_or_create (
939974 config,
940975 storage. 0 ,
941976 authorize_virtual_chunk_access,
977+ version,
942978 )
943979 . await
944980 . map_err ( PyIcechunkStoreError :: RepositoryError ) ?;
0 commit comments