File tree 4 files changed +41
-1
lines changed
4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 34
34
runs-on : ubuntu-latest
35
35
env :
36
36
SPARSEZOO_TEST_MODE : " true"
37
+ NM_DISABLE_ANALYTICS : " true"
37
38
needs : test-setup
38
39
if : ${{needs.test-setup.outputs.python-diff == 1}}
39
40
steps :
46
47
runs-on : ubuntu-latest
47
48
env :
48
49
SPARSEZOO_TEST_MODE : " true"
50
+ NM_DISABLE_ANALYTICS : " true"
49
51
needs : test-setup
50
52
if : ${{needs.test-setup.outputs.full-check == 1}}
51
53
steps :
Original file line number Diff line number Diff line change 53
53
# run tests for the repo
54
54
test :
55
55
@echo " Running python tests" ;
56
- SPARSEZOO_TEST_MODE=" true" pytest tests $(PYTEST_ARGS ) ;
56
+ SPARSEZOO_TEST_MODE=" true" NM_DISABLE_ANALYTICS= " true " pytest tests $(PYTEST_ARGS ) ;
57
57
58
58
# create docs
59
59
docs :
Original file line number Diff line number Diff line change @@ -106,15 +106,22 @@ def send_event(
106
106
event_name : str ,
107
107
event_params : Optional [Dict [str , str ]] = None ,
108
108
raise_errors : bool = False ,
109
+ _await_response : bool = False ,
109
110
):
110
111
"""
111
112
Send an event
112
113
113
114
:param event_name: the name of the event to send
114
115
:param event_params: optional dictionary of parameters to send with the event
115
116
:param raise_errors: True to raise any errors that occur, False otherwise
117
+ :param _await_response: (testing only) True to wait for analytics request
118
+ thread to complete before returning. Default False
116
119
"""
117
120
if self ._disabled :
121
+ if _await_response :
122
+ raise ValueError (
123
+ "_await_response cannot be set to True when analytics is disabled"
124
+ )
118
125
return
119
126
120
127
if not event_params :
@@ -149,6 +156,9 @@ def _send_request():
149
156
thread = threading .Thread (target = _send_request )
150
157
thread .start ()
151
158
159
+ if _await_response :
160
+ thread .join ()
161
+
152
162
153
163
# analytics client for sparsezoo, to disable set NM_DISABLE_ANALYTICS=1
154
164
sparsezoo_analytics = GoogleAnalytics ("sparsezoo" , sparsezoo_version )
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing,
10
+ # software distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from copy import deepcopy
16
+
17
+ from sparsezoo .analytics import sparsezoo_analytics
18
+
19
+
20
+ def test_send_event_success ():
21
+ test_analytics = deepcopy (sparsezoo_analytics )
22
+ test_analytics ._disabled = False
23
+
24
+ test_analytics .send_event (
25
+ "tests__analytics__test_send_event_success" ,
26
+ raise_errors = True ,
27
+ _await_response = True ,
28
+ )
You can’t perform that action at this time.
0 commit comments