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 coniguration option to control how Nuclio functions are invoked
11
+ (< https://github.com/opencv/cvat/pull/6146 > )
11
12
12
13
### Changed
13
14
- TDB
Original file line number Diff line number Diff line change @@ -86,14 +86,21 @@ def get(self, func_id):
86
86
return response
87
87
88
88
def invoke (self , func , payload ):
89
- if os .getenv ('KUBERNETES_SERVICE_HOST' ):
90
- return self ._http (method = "post" , url = '/api/function_invocations' ,
89
+ invoke_method = {
90
+ 'dashboard' : self ._invoke_via_dashboard ,
91
+ 'direct' : self ._invoke_directly ,
92
+ }
93
+
94
+ return invoke_method [settings .NUCLIO ['INVOKE_METHOD' ]](func , payload )
95
+
96
+ def _invoke_via_dashboard (self , func , payload ):
97
+ return self ._http (method = "post" , url = '/api/function_invocations' ,
91
98
data = payload , headers = {
92
99
'x-nuclio-function-name' : func .id ,
93
100
'x-nuclio-path' : '/'
94
101
})
95
102
96
- # Note: call the function directly without the nuclio dashboard
103
+ def _invoke_directly ( self , func , payload ):
97
104
# host.docker.internal for Linux will work only with Docker 20.10+
98
105
NUCLIO_TIMEOUT = settings .NUCLIO ['DEFAULT_TIMEOUT' ]
99
106
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