ratio1 3.4.37__py3-none-any.whl → 3.4.39__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ratio1/_ver.py CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "3.4.37"
1
+ __VER__ = "3.4.39"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -2789,15 +2789,58 @@ class GenericSession(BaseDecentrAIObject):
2789
2789
 
2790
2790
  return pipeline, instance
2791
2791
 
2792
+ def maybe_clean_kwargs(
2793
+ self, _kwargs: dict,
2794
+ caller_method_name: str,
2795
+ solver_method_name: str,
2796
+ parameters_to_remove: list[str]
2797
+ ):
2798
+ """
2799
+ This method is used to clean the kwargs dictionary before passing it to a solver method.
2800
+ It can also print warnings
2801
+ Parameters
2802
+ ----------
2803
+ _kwargs : dict
2804
+ The kwargs dictionary to clean.
2805
+ caller_method_name : str
2806
+ The name of the method that is calling this method.
2807
+ solver_method_name : str
2808
+ The name of the solver method that will receive the cleaned kwargs.
2809
+ parameters_to_remove : list[str]
2810
+ A list of parameters to remove from the kwargs dictionary.
2811
+
2812
+ Returns
2813
+ -------
2814
+ res : dict
2815
+ The cleaned kwargs dictionary.
2816
+ """
2817
+
2818
+ for _key in parameters_to_remove:
2819
+ if not isinstance(_key, str):
2820
+ continue
2821
+ # endif param_name not str
2822
+ if _key in _kwargs:
2823
+ _kwargs.pop(_key)
2824
+ warn_msg = f"WARNING! The '{caller_method_name}' passes its own `{_key}`, so the parameter is not used."
2825
+ warn_msg += f" Use '{solver_method_name}' instead if you want to use the `{_key}` parameter."
2826
+ self.log.P(warn_msg, color='y', show=True)
2827
+ # endif _key in _kwargs
2828
+ # endfor parameters to remove
2829
+
2830
+ return _kwargs
2831
+
2792
2832
  def create_web_app(
2793
2833
  self,
2794
2834
  *,
2795
2835
  node,
2796
2836
  name="Ratio1 Web App",
2797
2837
  signature=PLUGIN_SIGNATURES.GENERIC_WEB_APP,
2838
+ tunnel_engine="ngrok",
2839
+ tunnel_engine_enabled=True,
2840
+ cloudflare_token=None,
2798
2841
  ngrok_edge_label=None,
2842
+ ngrok_use_api=True,
2799
2843
  endpoints=None,
2800
- use_ngrok=True,
2801
2844
  extra_debug=False,
2802
2845
  summary="Ratio1 WebApp created via SDK",
2803
2846
  description=None,
@@ -2805,6 +2848,9 @@ class GenericSession(BaseDecentrAIObject):
2805
2848
  ):
2806
2849
  """
2807
2850
  Create a new generic web app on a node.
2851
+ If this uses tunnelling, the app will be exposed using either
2852
+ a cloudflare token, an ngrok edge label or an automatically generated URL.
2853
+ The URL can be automatically generated only in case of ngrok usage(which will also be discontinued).
2808
2854
 
2809
2855
  Parameters
2810
2856
  ----------
@@ -2817,17 +2863,48 @@ class GenericSession(BaseDecentrAIObject):
2817
2863
 
2818
2864
  signature : str, optional
2819
2865
  The signature of the plugin that will be used. Defaults to PLUGIN_SIGNATURES.CUSTOM_WEBAPI_01.
2820
-
2866
+
2867
+ tunnel_engine : str, optional
2868
+ The tunnel engine to use for exposing the web app. Defaults to "ngrok".
2869
+ It can also be "cloudflare" for Cloudflare Tunnel.
2870
+
2871
+ tunnel_engine_enabled : bool, optional
2872
+ If True, will use the specified tunnel engine to expose the web app. Defaults to True.
2873
+
2874
+ ngrok_edge_label : str, optional
2875
+ The label of the edge node that will be used to expose the HTTP server. Defaults to None.
2876
+
2877
+ cloudflare_token : str, optional
2878
+ The Cloudflare token to use for exposing the web app. Defaults to None.
2879
+
2821
2880
  endpoints : list[dict], optional
2822
2881
  A list of dictionaries defining the endpoint configuration. Defaults to None.
2823
-
2824
- use_ngrok : bool, optional
2825
- If True, will use ngrok to expose the web app. Defaults to True.
2826
-
2827
-
2828
2882
  """
2829
-
2830
- ngrok_use_api = True
2883
+ ngrok_kwargs = {}
2884
+ cloudflare_kwargs = {}
2885
+
2886
+ if tunnel_engine_enabled:
2887
+ if tunnel_engine == "ngrok":
2888
+ if not isinstance(ngrok_edge_label, str):
2889
+ ngrok_edge_label = None
2890
+ warn_msg = f"WARNING! Without a pre-defined `ngrok_edge_label`, the URL will be generated automatically, "
2891
+ warn_msg += "but it will not be persistent across restarts."
2892
+ self.P(warn_msg, color='y', show=True)
2893
+ # raise ValueError(f"`ngrok_edge_label` must be a string when using ngrok tunnel engine. {type(ngrok_edge_label)} provided")
2894
+ # endif ngrok edge label not valid
2895
+ ngrok_kwargs = {
2896
+ "ngrok_edge_label": ngrok_edge_label,
2897
+ "ngrok_use_api": ngrok_use_api,
2898
+ }
2899
+ elif tunnel_engine == "cloudflare":
2900
+ if not isinstance(cloudflare_token, str):
2901
+ raise ValueError(f"`cloudflare` must be a string when using cloudflare tunnel engine. {type(cloudflare_token)} provided.")
2902
+ cloudflare_kwargs = {
2903
+ "cloudflare_token": cloudflare_token,
2904
+ }
2905
+ else:
2906
+ raise ValueError("Unsupported tunnel engine: {}".format(tunnel_engine))
2907
+ # endif tunnel engine enabled
2831
2908
 
2832
2909
  pipeline_name = name.replace(" ", "_").lower()
2833
2910
 
@@ -2842,12 +2919,13 @@ class GenericSession(BaseDecentrAIObject):
2842
2919
  instance = pipeline.create_plugin_instance(
2843
2920
  signature=signature,
2844
2921
  instance_id=self.log.get_unique_id(),
2845
- use_ngrok=use_ngrok,
2846
- ngrok_edge_label=ngrok_edge_label,
2847
- ngrok_use_api=ngrok_use_api,
2922
+ tunnel_engine_enabled=tunnel_engine_enabled,
2923
+ tunnel_engine=tunnel_engine,
2848
2924
  api_title=name,
2849
2925
  api_summary=summary,
2850
2926
  api_description=description,
2927
+ **ngrok_kwargs,
2928
+ **cloudflare_kwargs,
2851
2929
  **kwargs
2852
2930
  )
2853
2931
 
@@ -2865,16 +2943,20 @@ class GenericSession(BaseDecentrAIObject):
2865
2943
  *,
2866
2944
  node,
2867
2945
  name="Ratio1 Custom Web API",
2946
+ tunnel_engine="ngrok",
2947
+ tunnel_engine_enabled=True,
2868
2948
  ngrok_edge_label=None,
2949
+ cloudflare_token=None,
2869
2950
  endpoints=None,
2870
- use_ngrok=True,
2871
2951
  extra_debug=False,
2872
2952
  summary="Ratio1 Web API created via SDK",
2873
2953
  description=None,
2874
2954
  **kwargs):
2875
2955
  """
2876
- Creates a custom Web API with endpoints on a node using custom code and either a pre-defined edge label or generates the URL automatically.
2877
-
2956
+ Creates a custom Web API with endpoints on a node using custom code.
2957
+ If this uses tunnelling, the app will be exposed using either
2958
+ a cloudflare token, an ngrok edge label or an automatically generated URL.
2959
+ The URL can be automatically generated only in case of ngrok usage(which will also be discontinued).
2878
2960
 
2879
2961
  Parameters
2880
2962
  ----------
@@ -2885,18 +2967,21 @@ class GenericSession(BaseDecentrAIObject):
2885
2967
  name : str
2886
2968
  Name of the web app.
2887
2969
 
2970
+ tunnel_engine : str, optional
2971
+ The tunnel engine to use for exposing the web app. Defaults to "ngrok".
2972
+ It can also be "cloudflare" for Cloudflare Tunnel.
2973
+
2974
+ tunnel_engine_enabled : bool, optional
2975
+ If True, will use the specified tunnel engine to expose the web app. Defaults to True.
2976
+
2888
2977
  ngrok_edge_label : str, optional
2889
2978
  The label of the edge node that will be used to expose the HTTP server. Defaults to None.
2890
2979
 
2891
- signature : str, optional
2892
- The signature of the plugin that will be used. Defaults to PLUGIN_SIGNATURES.CUSTOM_WEBAPI_01.
2980
+ cloudflare_token : str, optional
2981
+ The Cloudflare token to use for exposing the web app. Defaults to None.
2893
2982
 
2894
2983
  endpoints : list[dict], optional
2895
2984
  A list of dictionaries defining the endpoint configuration. Defaults to None.
2896
-
2897
- use_ngrok : bool, optional
2898
- If True, will use ngrok to expose the web app. Defaults to True.
2899
-
2900
2985
 
2901
2986
  Returns
2902
2987
  -------
@@ -2911,7 +2996,8 @@ class GenericSession(BaseDecentrAIObject):
2911
2996
  pipeline, instance = session.create_custom_webapi(
2912
2997
  node="node_name",
2913
2998
  name="My Custom Web API",
2914
- ngrok_edge_label=None, # no edge specified, will generate url automatically and return it at deploy
2999
+ tunnel_engine='cloudflare',
3000
+ cloudflare_token="<cloudflare_token>",
2915
3001
  endpoints=[
2916
3002
  {
2917
3003
  "path": "/my_endpoint",
@@ -2919,7 +3005,6 @@ class GenericSession(BaseDecentrAIObject):
2919
3005
  "handler": my_handler_function,
2920
3006
  },
2921
3007
  ],
2922
- use_ngrok=True,
2923
3008
  extra_debug=True,
2924
3009
  summary="My Custom Web API",
2925
3010
  description="This is a custom web API created via the SDK.",
@@ -2930,13 +3015,21 @@ class GenericSession(BaseDecentrAIObject):
2930
3015
 
2931
3016
 
2932
3017
  """
3018
+ kwargs = self.maybe_clean_kwargs(
3019
+ _kwargs=kwargs,
3020
+ caller_method_name="create_custom_webapi",
3021
+ solver_method_name="create_web_app",
3022
+ parameters_to_remove=["signature"]
3023
+ )
2933
3024
  return self.create_web_app(
2934
3025
  node=node,
2935
3026
  name=name,
2936
3027
  signature=PLUGIN_SIGNATURES.CUSTOM_WEBAPI_01,
3028
+ tunnel_engine=tunnel_engine,
3029
+ tunnel_engine_enabled=tunnel_engine_enabled,
3030
+ cloudflare_token=cloudflare_token,
2937
3031
  ngrok_edge_label=ngrok_edge_label,
2938
3032
  endpoints=endpoints,
2939
- use_ngrok=use_ngrok,
2940
3033
  extra_debug=extra_debug,
2941
3034
  summary=summary,
2942
3035
  description=description,
@@ -2948,8 +3041,10 @@ class GenericSession(BaseDecentrAIObject):
2948
3041
  *,
2949
3042
  node,
2950
3043
  name="Ratio1 Container Web App",
2951
- signature=PLUGIN_SIGNATURES.CONTAINER_APP_RUNNER,
2952
- use_ngrok=True,
3044
+ tunnel_engine_enabled=True,
3045
+ tunnel_engine="ngrok",
3046
+ cloudflare_token=None,
3047
+ ngrok_edge_label=None,
2953
3048
  extra_debug=False,
2954
3049
  summary="Ratio1 Container WebApp created via SDK",
2955
3050
  description=None,
@@ -2967,39 +3062,40 @@ class GenericSession(BaseDecentrAIObject):
2967
3062
  name : str
2968
3063
  Name of the container web app.
2969
3064
 
2970
- signature : str, optional
2971
- The signature of the plugin that will be used. Defaults to PLUGIN_SIGNATURES.CONTAINER_APP_RUNNER.
3065
+ tunnel_engine : str, optional
3066
+ The tunnel engine to use for exposing the web app. Defaults to "ngrok".
3067
+ It can also be "cloudflare" for Cloudflare Tunnel.
2972
3068
 
2973
- use_ngrok : bool, optional
2974
- If True, will use ngrok to expose the web app. Defaults to True.
2975
- """
3069
+ tunnel_engine_enabled : bool, optional
3070
+ If True, will use the specified tunnel engine to expose the web app. Defaults to True.
2976
3071
 
2977
- ngrok_use_api = True
3072
+ ngrok_edge_label : str, optional
3073
+ The label of the edge node that will be used to expose the HTTP server. Defaults to None.
2978
3074
 
2979
- pipeline_name = name.replace(" ", "_").lower()
3075
+ cloudflare_token : str, optional
3076
+ The Cloudflare token to use for exposing the web app. Defaults to None.
2980
3077
 
2981
- pipeline: WebappPipeline = self.create_pipeline(
3078
+ """
3079
+ kwargs = self.maybe_clean_kwargs(
3080
+ _kwargs=kwargs,
3081
+ caller_method_name="create_container_web_app",
3082
+ solver_method_name="create_web_app",
3083
+ parameters_to_remove=["signature"]
3084
+ )
3085
+ return self.create_web_app(
2982
3086
  node=node,
2983
- name=pipeline_name,
2984
- pipeline_type=WebappPipeline,
3087
+ name=name,
3088
+ signature=PLUGIN_SIGNATURES.CONTAINER_APP_RUNNER,
3089
+ tunnel_engine=tunnel_engine,
3090
+ tunnel_engine_enabled=tunnel_engine_enabled,
3091
+ cloudflare_token=cloudflare_token,
3092
+ ngrok_edge_label=ngrok_edge_label,
2985
3093
  extra_debug=extra_debug,
2986
- # default TYPE is "Void"
2987
- )
2988
-
2989
- instance = pipeline.create_plugin_instance(
2990
- signature=signature,
2991
- instance_id=self.log.get_unique_id(),
2992
- use_ngrok=use_ngrok,
2993
- ngrok_use_api=ngrok_use_api,
2994
- api_title=name,
2995
- api_summary=summary,
2996
- api_description=description,
3094
+ summary=summary,
3095
+ description=description,
2997
3096
  **kwargs
2998
3097
  )
2999
3098
 
3000
- return pipeline, instance
3001
-
3002
-
3003
3099
  def deeploy_launch_container_app(
3004
3100
  self,
3005
3101
  docker_image: str,
@@ -3798,7 +3894,10 @@ class GenericSession(BaseDecentrAIObject):
3798
3894
  *,
3799
3895
  node,
3800
3896
  name="Ratio1 HTTP Server",
3897
+ tunnel_engine="ngrok",
3898
+ tunnel_engine_enabled=True,
3801
3899
  ngrok_edge_label=None,
3900
+ cloudflare_token=None,
3802
3901
  endpoints=None,
3803
3902
  extra_debug=False,
3804
3903
  summary="Ratio1 HTTP Server created via SDK",
@@ -3814,15 +3913,26 @@ class GenericSession(BaseDecentrAIObject):
3814
3913
  Parameters
3815
3914
  ----------
3816
3915
 
3916
+
3817
3917
  node : str
3818
- Address or Name of the ratio1 Edge Protocol edge node that will handle this HTTP server.
3918
+ Address or Name of the ratio1 Edge Protocol edge node that will handle this web app.
3819
3919
 
3820
3920
  name : str
3821
- Name of the HTTP server.
3921
+ Name of the web app.
3922
+
3923
+ tunnel_engine : str, optional
3924
+ The tunnel engine to use for exposing the web app. Defaults to "ngrok".
3925
+ It can also be "cloudflare" for Cloudflare Tunnel.
3926
+
3927
+ tunnel_engine_enabled : bool, optional
3928
+ If True, will use the specified tunnel engine to expose the web app. Defaults to True.
3822
3929
 
3823
3930
  ngrok_edge_label : str, optional
3824
3931
  The label of the edge node that will be used to expose the HTTP server. Defaults to None.
3825
3932
 
3933
+ cloudflare_token : str, optional
3934
+ The Cloudflare token to use for exposing the web app. Defaults to None.
3935
+
3826
3936
  endpoints : list[dict], optional
3827
3937
  A list of dictionaries defining the endpoint configuration. Defaults to None.
3828
3938
 
@@ -3844,10 +3954,19 @@ class GenericSession(BaseDecentrAIObject):
3844
3954
  static_directory = static_directory or '.'
3845
3955
  self.__is_static_directory_valid(static_directory, raise_exception=True)
3846
3956
  endpoints = self.__maybe_add_root_endpoint(endpoints)
3957
+ kwargs = self.maybe_clean_kwargs(
3958
+ _kwargs=kwargs,
3959
+ caller_method_name="create_http_server",
3960
+ solver_method_name="create_web_app",
3961
+ parameters_to_remove=["signature"]
3962
+ )
3847
3963
  return self.create_web_app(
3848
3964
  node=node,
3849
3965
  name=name,
3850
3966
  signature=PLUGIN_SIGNATURES.GENERIC_HTTP_SERVER,
3967
+ tunnel_engine=tunnel_engine,
3968
+ tunnel_engine_enabled=tunnel_engine_enabled,
3969
+ cloudflare_token=cloudflare_token,
3851
3970
  ngrok_edge_label=ngrok_edge_label,
3852
3971
  endpoints=endpoints,
3853
3972
  extra_debug=extra_debug,
@@ -3865,7 +3984,9 @@ class GenericSession(BaseDecentrAIObject):
3865
3984
  *,
3866
3985
  nodes,
3867
3986
  name,
3868
- ngrok_edge_label,
3987
+ ngrok_edge_label=None,
3988
+ cloudflare_token=None,
3989
+ tunnel_engine="ngrok",
3869
3990
  signature=PLUGIN_SIGNATURES.GENERIC_WEB_APP,
3870
3991
  endpoints=None,
3871
3992
  extra_debug=False,
@@ -3894,6 +4015,13 @@ class GenericSession(BaseDecentrAIObject):
3894
4015
  The label of the edge node that will be used to expose the web app. This is mandatory due to the fact
3895
4016
  that the web app will be exposed using ngrok from multiple nodes that all will share the same edge label.
3896
4017
 
4018
+ cloudflare_token : str, optional
4019
+ The Cloudflare token to use for exposing the web app. Defaults to None.
4020
+
4021
+ tunnel_engine : str, optional
4022
+ The tunnel engine to use for exposing the web app. Defaults to "ngrok".
4023
+ It can also be "cloudflare" for Cloudflare Tunnel.
4024
+
3897
4025
  endpoints : list[dict], optional
3898
4026
  A list of dictionaries defining the endpoint configuration. Defaults to None.
3899
4027
 
@@ -3902,40 +4030,40 @@ class GenericSession(BaseDecentrAIObject):
3902
4030
  """
3903
4031
 
3904
4032
  ngrok_use_api = kwargs.pop('ngrok_use_api', True)
3905
- use_ngrok = True
3906
- kwargs.pop('use_ngrok', None)
3907
4033
 
3908
- if ngrok_edge_label is None:
3909
- raise ValueError("The `ngrok_edge_label` parameter is mandatory when creating a balanced web app, in order for all instances to respond to the same URL.")
4034
+ if tunnel_engine == "ngrok" and ngrok_edge_label is None:
4035
+ err_msg = f"The `ngrok_edge_label` parameter is mandatory when creating a balanced web app tunneled with ngrok."
4036
+ err_msg += "This is needed in order for all instances to respond to the same URL."
4037
+ raise ValueError(err_msg)
4038
+ # endif ngrok used and ngrok_edge_label is None
4039
+
4040
+ kwargs = self.maybe_clean_kwargs(
4041
+ _kwargs=kwargs,
4042
+ caller_method_name="create_and_deploy_balanced_web_app",
4043
+ solver_method_name="create_web_app",
4044
+ parameters_to_remove=[
4045
+ "tunnel_engine_enabled"
4046
+ ]
4047
+ )
3910
4048
 
3911
4049
  pipelines, instances = [], []
3912
4050
 
3913
4051
  for node in nodes:
3914
4052
  self.P("Creating web app on node {}...".format(node), color='b')
3915
- pipeline: WebappPipeline = self.create_pipeline(
4053
+
4054
+ pipeline, instance = self.create_web_app(
3916
4055
  node=node,
3917
4056
  name=name,
3918
- pipeline_type=WebappPipeline,
3919
- extra_debug=extra_debug,
3920
- # default TYPE is "Void"
3921
- )
3922
-
3923
- instance = pipeline.create_plugin_instance(
3924
4057
  signature=signature,
3925
- instance_id=self.log.get_unique_id(),
3926
- use_ngrok=use_ngrok,
4058
+ tunnel_engine=tunnel_engine,
4059
+ tunnel_engine_enabled=True,
4060
+ cloudflare_token=cloudflare_token,
3927
4061
  ngrok_edge_label=ngrok_edge_label,
3928
4062
  ngrok_use_api=ngrok_use_api,
4063
+ endpoints=endpoints,
4064
+ extra_debug=extra_debug,
3929
4065
  **kwargs
3930
4066
  )
3931
-
3932
- if endpoints is not None:
3933
- for endpoint in endpoints:
3934
- assert isinstance(endpoint, dict), "Each endpoint must be a dictionary defining the endpoint configuration."
3935
- instance.add_new_endpoint(**endpoint)
3936
- # end for
3937
- # end if we have endpoints defined in the call
3938
-
3939
4067
  pipeline.deploy()
3940
4068
  pipelines.append(pipeline)
3941
4069
  instances.append(instance)
@@ -3981,6 +4109,8 @@ class GenericSession(BaseDecentrAIObject):
3981
4109
  nodes,
3982
4110
  name="Ratio1 HTTP Server",
3983
4111
  ngrok_edge_label=None,
4112
+ cloudflare_token=None,
4113
+ tunnel_engine="ngrok",
3984
4114
  endpoints=None,
3985
4115
  extra_debug=False,
3986
4116
  summary="Ratio1 HTTP Server created via SDK",
@@ -3996,7 +4126,7 @@ class GenericSession(BaseDecentrAIObject):
3996
4126
  Parameters
3997
4127
  ----------
3998
4128
 
3999
- nodes : str
4129
+ nodes : list
4000
4130
  List of addresses or Names of the ratio1 Edge Protocol edge nodes that will handle this HTTP server.
4001
4131
 
4002
4132
  name : str
@@ -4030,6 +4160,8 @@ class GenericSession(BaseDecentrAIObject):
4030
4160
  nodes=nodes,
4031
4161
  name=name,
4032
4162
  signature=PLUGIN_SIGNATURES.GENERIC_HTTP_SERVER,
4163
+ tunnel_engine=tunnel_engine,
4164
+ cloudflare_token=cloudflare_token,
4033
4165
  ngrok_edge_label=ngrok_edge_label,
4034
4166
  endpoints=endpoints,
4035
4167
  extra_debug=extra_debug,
@@ -25,7 +25,7 @@ class WebappPipeline(Pipeline):
25
25
  This is a special type of pipeline that is used to deploy webapps.
26
26
  It will override the deploy method to return the ngrok URL as well as the on_data method to extract the ngrok URL.
27
27
  """
28
- self.ngrok_url = None
28
+ self.app_url = None
29
29
  self.__extra_debug = extra_debug
30
30
  _on_data = [self.__check_payloads, on_data]
31
31
  super().__init__(
@@ -70,7 +70,7 @@ class WebappPipeline(Pipeline):
70
70
  if self.__extra_debug:
71
71
  self.P(f"Received payload from {plugin_signature} ({plugin_instance})")
72
72
  if "NGROK_URL" in data:
73
- self.ngrok_url = data["NGROK_URL"]
73
+ self.app_url = data["NGROK_URL"]
74
74
  return
75
75
 
76
76
  def create_plugin_instance(
@@ -78,19 +78,40 @@ class WebappPipeline(Pipeline):
78
78
  *,
79
79
  signature,
80
80
  instance_id,
81
- config={},
81
+ config={},
82
+ tunnel_engine='ngrok',
83
+ tunnel_engine_enabled=True,
82
84
  ngrok_edge_label=None,
85
+ cloudflare_token=None,
83
86
  **kwargs
84
87
  ):
85
-
86
- if ngrok_edge_label is not None:
87
- self.ngrok_url = "URL_DEFINED_IN_EDGE_LABEL"
88
+ tunnel_kwargs = {
89
+ 'tunnel_engine': tunnel_engine,
90
+ 'tunnel_engine_enabled': tunnel_engine_enabled,
91
+ }
92
+ if not tunnel_engine_enabled:
93
+ self.app_url = "TUNNEL_ENGINE_DISABLED"
94
+ else:
95
+ if tunnel_engine.lower() == 'cloudflare':
96
+ if cloudflare_token is None:
97
+ raise ValueError("Cloudflare token must be provided when using Cloudflare as tunnel engine.")
98
+ self.P("Using Cloudflare as tunnel engine", color="green")
99
+ self.app_url = "URL_DEFINED_IN_CLOUDFLARE_TOKEN"
100
+ tunnel_kwargs['cloudflare_token'] = cloudflare_token
101
+ else:
102
+ self.P("Using ngrok as tunnel engine", color="green")
103
+ if ngrok_edge_label is not None:
104
+ self.app_url = "URL_DEFINED_IN_NGROK_EDGE_LABEL"
105
+ tunnel_kwargs['ngrok_edge_label'] = ngrok_edge_label
106
+ # endif ngrok_edge_label is not None
107
+ # endif tunnel_engine ngrok or cloudflare
108
+ # endif tunnel_engine_enabled
88
109
 
89
110
  return super().create_plugin_instance(
90
111
  signature=signature,
91
112
  instance_id=instance_id,
92
- config=config,
93
- ngrok_edge_label=ngrok_edge_label,
113
+ config=config,
114
+ **tunnel_kwargs,
94
115
  **kwargs
95
116
  )
96
117
 
@@ -106,11 +127,11 @@ class WebappPipeline(Pipeline):
106
127
  res = super().deploy(verbose=verbose, timeout=timeout, **kwargs)
107
128
  # now we wait for the ngrok url to be available
108
129
  start = time.time()
109
- while self.ngrok_url is None:
130
+ while self.app_url is None:
110
131
  elapsed = time.time() - start
111
132
  if elapsed > timeout:
112
133
  msg = "Timeout waiting for ngrok url"
113
134
  self.P(msg, color="red")
114
135
  raise Exception(msg)
115
136
  # return the ngrok url
116
- return self.ngrok_url
137
+ return self.app_url
ratio1/const/evm_net.py CHANGED
@@ -337,7 +337,6 @@ EVM_NET_CONSTANTS = {
337
337
  EvmNetConstants.SEED_NODES_ADDRESSES_KEY: [
338
338
  "0xai_AhIQz47-2dpbncDTODXcP7_cByr0_CI9VEB1dCXnbbG7", # dr1s-01
339
339
  "0xai_AgnygSlY8BwnmaCj6mItg36JHlG_Lh3UqqFaTPbuNzy0", # dr1s-02
340
- "0xai_A74xZKZJa4LekjvJ6oJz29qxOOs5nLClXAZEhYv59t3Z", # dr1s-db-1
341
340
  ],
342
341
  },
343
342
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ratio1
3
- Version: 3.4.37
3
+ Version: 3.4.39
4
4
  Summary: `ratio1` or Ration1 SDK is the Python SDK required for client app development for the Ratio1 ecosystem
5
5
  Project-URL: Homepage, https://github.com/Ratio1/ratio1_sdk
6
6
  Project-URL: Bug Tracker, https://github.com/Ratio1/ratio1_sdk/issues
@@ -1,16 +1,16 @@
1
1
  ratio1/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- ratio1/_ver.py,sha256=jOqTWk2eCBYGGmkIbQvD17_xFaS8OOkly_YtMQztOZ4,331
2
+ ratio1/_ver.py,sha256=ABDRSXrsWdo9F3E_13s2gVLWdHtO1ykuvzBGeSroSHg,331
3
3
  ratio1/base_decentra_object.py,sha256=iXvAAf6wPnGWzeeiRfwLojVoan-m1e_VsyPzjUQuENo,4492
4
4
  ratio1/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
5
5
  ratio1/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
6
6
  ratio1/base/distributed_custom_code_presets.py,sha256=cvz5R88P6Z5V61Ce1vHVVh8bOkgXd6gve_vdESDNAsg,2544
7
- ratio1/base/generic_session.py,sha256=fzpAIqRJbwiBrpFqHXCHxvakAves7cbXRrHURLelffI,179566
7
+ ratio1/base/generic_session.py,sha256=CaDFbcAd7oefVCQFKYA0r-H5FU6FTxG3By-eQDvt1qU,185384
8
8
  ratio1/base/instance.py,sha256=oQvwzzRvir7851wyhDx_BwN6y_VgsNWwYo53vN33QI4,21914
9
9
  ratio1/base/pipeline.py,sha256=szoHrk1qBdY6NKPUk3tUTsJx3XzYp5C2GTOlzRiQi48,62489
10
10
  ratio1/base/plugin_template.py,sha256=Gs438cSkhvxPujE4CRH_32pcuZaVwI9kia8E4VDRpSU,138794
11
11
  ratio1/base/responses.py,sha256=ZKBZmRhYDv8M8mQ5C_ahGsQvtWH4b9ImRcuerQdZmNw,6937
12
12
  ratio1/base/transaction.py,sha256=l2JCzTgH3-irFwCEBGrS3z8VOisA8GdC3zEfqgJOTG4,5138
13
- ratio1/base/webapp_pipeline.py,sha256=ZNGqZ36DY076XVDfGu2Q61kCt3kxIJ4Mi4QbPZuDVn0,2791
13
+ ratio1/base/webapp_pipeline.py,sha256=zjiLzGnsUEfrSyHWMDoiwQWheM-MXQOeR3YKfFPKXiE,3706
14
14
  ratio1/base/payload/__init__.py,sha256=y8fBI8tG2ObNfaXFWjyWZXwu878FRYj_I8GIbHT4GKE,29
15
15
  ratio1/base/payload/payload.py,sha256=MoCeL6iZzl1an-4eqRpLW0iz6Yk3OvlBrymcmhWeecM,2689
16
16
  ratio1/bc/__init__.py,sha256=BI5pcqHdhwnMdbWTYDLW1cVP_844VtLra-lz7xprgsk,171
@@ -42,7 +42,7 @@ ratio1/const/apps.py,sha256=0NiuoAPak0HjEULF3fs3xaUH8IRSZ0i4fZw7T2fEd_g,785
42
42
  ratio1/const/base.py,sha256=0K1zhAkU_LmZosnz1UMmBhmYpVt5QVBPy9FkeLQlAFY,5955
43
43
  ratio1/const/comms.py,sha256=qEYX4ciYg8SYWSDZZTUYxzpR1--2a7UusrWzAq0hxo8,2259
44
44
  ratio1/const/environment.py,sha256=632L5GrcNqF3-JhvrC6kXzXwLMcihRgMlOkLurnOwGY,1031
45
- ratio1/const/evm_net.py,sha256=NPfOjLizfzjettWLzpLtilu_tcTffJP8h4hGSALWhKQ,11468
45
+ ratio1/const/evm_net.py,sha256=86ZG8_1tiLxLfH2ud8i-gD1VxGk-PpZTlS-f4XJgm8U,11396
46
46
  ratio1/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
47
47
  ratio1/const/heartbeat.py,sha256=diQcAUZDNL2oJpWgh4JORhfBB6dvLa8ZW7Ce-xM-IcU,2655
48
48
  ratio1/const/misc.py,sha256=VDCwwpf5bl9ltx9rzT2WPVP8B3mZFRufU1tSS5MO240,413
@@ -103,8 +103,8 @@ ratio1/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,10
103
103
  ratio1/utils/config.py,sha256=IMXAN9bpHePKEuTFGRRqFJXz_vBa-wi7s9gLhFEheRY,9953
104
104
  ratio1/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
105
105
  ratio1/utils/oracle_sync/oracle_tester.py,sha256=aJOPcZhtbw1XPqsFG4qYpfv2Taj5-qRXbwJzrPyeXDE,27465
106
- ratio1-3.4.37.dist-info/METADATA,sha256=MucFLKDGwWBSuCwv4mRGLP5dYZT30PMK7IclS32gauc,12248
107
- ratio1-3.4.37.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
108
- ratio1-3.4.37.dist-info/entry_points.txt,sha256=DR_olREzU1egwmgek3s4GfQslBi-KR7lXsd4ap0TFxE,46
109
- ratio1-3.4.37.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
110
- ratio1-3.4.37.dist-info/RECORD,,
106
+ ratio1-3.4.39.dist-info/METADATA,sha256=Ox5xn1ySF8iu38F1QY5yDslBg4rkNNpQ6k2uolDFD5I,12248
107
+ ratio1-3.4.39.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
108
+ ratio1-3.4.39.dist-info/entry_points.txt,sha256=DR_olREzU1egwmgek3s4GfQslBi-KR7lXsd4ap0TFxE,46
109
+ ratio1-3.4.39.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
110
+ ratio1-3.4.39.dist-info/RECORD,,