File tree 4 files changed +28
-1
lines changed
4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ Change Log
13
13
14
14
Unreleased
15
15
16
+ [1.44.2] - 2023-09-11
17
+ ---------------------
18
+ * fix: chunked data at 50000 byte in EMSI client for xblock-skills job
19
+
16
20
[1.44.1] - 2023-08-25
17
21
---------------------
18
22
* feat: add prefetch related to the whitelisted product skills
Original file line number Diff line number Diff line change 15
15
# 2. MINOR version when you add functionality in a backwards compatible manner, and
16
16
# 3. PATCH version when you make backwards compatible bug fixes.
17
17
# More details can be found at https://semver.org/
18
- __version__ = '1.44.1 '
18
+ __version__ = '1.44.2 '
19
19
20
20
default_app_config = 'taxonomy.apps.TaxonomyConfig' # pylint: disable=invalid-name
Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ class EMSISkillsApiClient(JwtEMSIApiClient):
183
183
"""
184
184
185
185
API_BASE_URL = urljoin (JwtEMSIApiClient .API_BASE_URL , '/skills/versions/8.9' )
186
+ MAX_LIGHTCAST_DATA_SIZE = 50000 # Maximum 50,000-byte data is supported by LightCast
186
187
187
188
def __init__ (self ):
188
189
"""
@@ -229,6 +230,11 @@ def get_product_skills(self, text_data):
229
230
Returns:
230
231
dict: A dictionary containing details of all the skills.
231
232
"""
233
+
234
+ if text_data and len (text_data ) > self .MAX_LIGHTCAST_DATA_SIZE :
235
+ # Truncate the text_data to 50,000 bytes since only 50,000-byte data is supported by LightCast
236
+ text_data = text_data [:self .MAX_LIGHTCAST_DATA_SIZE ]
237
+
232
238
data = {
233
239
'text' : text_data
234
240
}
Original file line number Diff line number Diff line change 5
5
6
6
import logging
7
7
from time import time
8
+ from unittest import mock
9
+ from faker import Faker
8
10
9
11
import responses
10
12
from pytest import raises
@@ -161,6 +163,21 @@ def test_get_product_skills(self):
161
163
162
164
assert skills == SKILLS_EMSI_CLIENT_RESPONSE
163
165
166
+ def test_get_product_skills_large_text (self ):
167
+ """
168
+ Validate that the behavior of client while fetching product skills for very large text.
169
+ """
170
+ api_response = mock .Mock ()
171
+ api_response .json .return_value = SKILLS_EMSI_RESPONSE
172
+ self .client .is_token_expired = mock .Mock (return_value = False )
173
+ self .client .client = mock .MagicMock (post = mock .Mock (return_value = api_response ))
174
+
175
+ max_data_size = self .client .MAX_LIGHTCAST_DATA_SIZE
176
+ skill_text_data = Faker ().text (max_data_size + max_data_size * 0.1 )
177
+ self .client .get_product_skills (skill_text_data )
178
+
179
+ assert len (self .client .client .post .call_args_list [0 ][1 ]['json' ]['text' ]) == max_data_size
180
+
164
181
@mock_api_response (
165
182
method = responses .POST ,
166
183
url = EMSISkillsApiClient .API_BASE_URL + '/extract' ,
You can’t perform that action at this time.
0 commit comments