File tree 3 files changed +17
-5
lines changed
3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## \[ 2.5.0] - Unreleased
9
9
### Added
10
- - TDB
10
+ - A configuration option to control how Nuclio functions are invoked
11
+ (< https://github.com/opencv/cvat/pull/6146 > )
11
12
12
13
### Changed
13
14
- Running SAM masks decoder on frontend (< https://github.com/opencv/cvat/pull/6019 > )
Original file line number Diff line number Diff line change @@ -89,14 +89,21 @@ def get(self, func_id):
89
89
return response
90
90
91
91
def invoke (self , func , payload ):
92
- if os .getenv ('KUBERNETES_SERVICE_HOST' ):
93
- return self ._http (method = "post" , url = '/api/function_invocations' ,
92
+ invoke_method = {
93
+ 'dashboard' : self ._invoke_via_dashboard ,
94
+ 'direct' : self ._invoke_directly ,
95
+ }
96
+
97
+ return invoke_method [settings .NUCLIO ['INVOKE_METHOD' ]](func , payload )
98
+
99
+ def _invoke_via_dashboard (self , func , payload ):
100
+ return self ._http (method = "post" , url = '/api/function_invocations' ,
94
101
data = payload , headers = {
95
102
'x-nuclio-function-name' : func .id ,
96
103
'x-nuclio-path' : '/'
97
104
})
98
105
99
- # Note: call the function directly without the nuclio dashboard
106
+ def _invoke_directly ( self , func , payload ):
100
107
# host.docker.internal for Linux will work only with Docker 20.10+
101
108
NUCLIO_TIMEOUT = settings .NUCLIO ['DEFAULT_TIMEOUT' ]
102
109
if os .path .exists ('/.dockerenv' ): # inside a docker container
Original file line number Diff line number Diff line change @@ -333,9 +333,13 @@ class CVAT_QUEUES(Enum):
333
333
'HOST' : os .getenv ('CVAT_NUCLIO_HOST' , 'localhost' ),
334
334
'PORT' : int (os .getenv ('CVAT_NUCLIO_PORT' , 8070 )),
335
335
'DEFAULT_TIMEOUT' : int (os .getenv ('CVAT_NUCLIO_DEFAULT_TIMEOUT' , 120 )),
336
- 'FUNCTION_NAMESPACE' : os .getenv ('CVAT_NUCLIO_FUNCTION_NAMESPACE' , 'nuclio' )
336
+ 'FUNCTION_NAMESPACE' : os .getenv ('CVAT_NUCLIO_FUNCTION_NAMESPACE' , 'nuclio' ),
337
+ 'INVOKE_METHOD' : os .getenv ('CVAT_NUCLIO_INVOKE_METHOD' ,
338
+ default = 'dashboard' if 'KUBERNETES_SERVICE_HOST' in os .environ else 'direct' ),
337
339
}
338
340
341
+ assert NUCLIO ['INVOKE_METHOD' ] in {'dashboard' , 'direct' }
342
+
339
343
RQ_SHOW_ADMIN_LINK = True
340
344
RQ_EXCEPTION_HANDLERS = [
341
345
'cvat.apps.engine.views.rq_exception_handler' ,
You can’t perform that action at this time.
0 commit comments