1919from typing import TYPE_CHECKING
2020
2121from grakn .api .options import GraknClusterOptions , GraknOptions
22- from grakn .api .session import GraknSession
23- from grakn .api .transaction import GraknTransaction
22+ from grakn .api .session import GraknSession , SessionType
23+ from grakn .api .transaction import TransactionType
2424from grakn .cluster .database import _ClusterDatabase
2525from grakn .cluster .failsafe_task import _FailsafeTask
2626from grakn .core .database import _CoreDatabase
3232
3333class _ClusterSession (GraknSession ):
3434
35- def __init__ (self , cluster_client : "_ClusterClient" , server_address : str , database : str , session_type : GraknSession . Type , options : GraknClusterOptions ):
35+ def __init__ (self , cluster_client : "_ClusterClient" , server_address : str , database : str , session_type : SessionType , options : GraknClusterOptions ):
3636 self .cluster_client = cluster_client
3737 self .core_client = cluster_client .core_client (server_address )
3838 print ("Opening a session to '%s'" % server_address )
3939 self .core_session = self .core_client .session (database , session_type , options )
4040 self ._options = options
4141
42- def transaction (self , transaction_type : GraknTransaction . Type , options : GraknClusterOptions = None ) -> _CoreTransaction :
42+ def transaction (self , transaction_type : TransactionType , options : GraknClusterOptions = None ) -> _CoreTransaction :
4343 if not options :
4444 options = GraknOptions .cluster ()
4545 return self ._transaction_any_replica (transaction_type , options ) if options .read_any_replica else self ._transaction_primary_replica (transaction_type , options )
4646
47- def _transaction_primary_replica (self , transaction_type : GraknTransaction . Type , options : GraknClusterOptions ) -> _CoreTransaction :
47+ def _transaction_primary_replica (self , transaction_type : TransactionType , options : GraknClusterOptions ) -> _CoreTransaction :
4848 return _TransactionFailsafeTask (self , transaction_type , options ).run_primary_replica ()
4949
50- def _transaction_any_replica (self , transaction_type : GraknTransaction . Type , options : GraknClusterOptions ) -> _CoreTransaction :
50+ def _transaction_any_replica (self , transaction_type : TransactionType , options : GraknClusterOptions ) -> _CoreTransaction :
5151 return _TransactionFailsafeTask (self , transaction_type , options ).run_any_replica ()
5252
53- def session_type (self ) -> GraknSession . Type :
53+ def session_type (self ) -> SessionType :
5454 return self .core_session .session_type ()
5555
5656 def options (self ) -> GraknClusterOptions :
@@ -76,7 +76,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
7676
7777class _TransactionFailsafeTask (_FailsafeTask ):
7878
79- def __init__ (self , cluster_session : _ClusterSession , transaction_type : GraknTransaction . Type , options : GraknClusterOptions ):
79+ def __init__ (self , cluster_session : _ClusterSession , transaction_type : TransactionType , options : GraknClusterOptions ):
8080 super ().__init__ (cluster_session .cluster_client , cluster_session .database ().name ())
8181 self .cluster_session = cluster_session
8282 self .transaction_type = transaction_type
0 commit comments