Skip to content

Commit 53c73d7

Browse files
committed
default 10k limit on list_funcs
test perf updates
1 parent a1e679c commit 53c73d7

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Unreleased
66

77
**Changes**
88
- `register_model` task automatically captures installed Python packages.
9+
- All `list_xxx` methods return all matching items unless a `limit` parameter is specified.
910
- Improved API documentation
1011

1112

src/sasctl/_services/service.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ def list_items(cls, filter=None, start=None, limit=None, **kwargs):
217217
kwargs['start'] = int(start)
218218
if limit is not None:
219219
kwargs['limit'] = int(limit)
220+
else:
221+
# Until search is more precise, try to pull all results
222+
# Needed until transparent pagination is implemented.
223+
kwargs['limit'] = int(1e4)
220224

221225
params = '&'.join(['%s=%s' % (k, quote(str(v), safe='/(),"'))
222226
for k, v in six.iteritems(kwargs)])

tests/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,18 @@ def add_placeholder(pattern, string, placeholder, group):
7070
from .matcher import PartialBodyMatcher
7171
betamax.Betamax.register_request_matcher(PartialBodyMatcher)
7272

73+
# Replay cassettes only by default
74+
# Can be overridden as necessary to update cassettes
75+
# See https://betamax.readthedocs.io/en/latest/record_modes.html for details.
76+
os.environ.setdefault('SASCTL_RECORD_MODE', 'once')
77+
if os.environ['SASCTL_RECORD_MODE'] \
78+
not in ('once', 'new_episodes', 'all', 'none'):
79+
os.environ['SASCTL_RECORD_MODE'] = 'once'
80+
7381
with betamax.Betamax.configure() as config:
7482
config.cassette_library_dir = "tests/cassettes"
75-
config.default_cassette_options['record_mode'] = 'once'
83+
config.default_cassette_options['record_mode'] = os.environ[
84+
'SASCTL_RECORD_MODE']
7685
config.default_cassette_options['match_requests_on'] = ['method',
7786
'redacted_path',
7887
# 'partial_body',
@@ -207,7 +216,6 @@ def cas_session(request, credentials):
207216
warnings.simplefilter('ignore')
208217
cassette_name = _casette_name(request, parametrized=False) + '_swat'
209218

210-
211219
# Must have an existing Session for Betamax to record
212220
recorded_session = requests.Session()
213221

tests/integration/test_model_publish.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ def test_get_publish_destination(self):
2727
assert dest.destinationType == 'microAnalyticService'
2828

2929
def test_create_cas_destination(self):
30-
dest = mp.create_cas_destination('caslocal', 'Public', 'sasctl_models',
30+
dest = mp.create_cas_destination('sasctlcas', 'Public', 'sasctl_models',
3131
description='Test CAS publish destination from sasctl.')
3232

33-
assert dest.name == 'caslocal'
33+
assert dest.name == 'sasctlcas'
3434
assert dest.destinationType == 'cas'
3535
assert dest.casLibrary == 'Public'
3636
assert dest.casServerName == 'cas-shared-default'
3737
assert dest.destinationTable == 'sasctl_models'
3838
assert dest.description == 'Test CAS publish destination from sasctl.'
3939

4040
def test_create_mas_destination(self):
41-
dest = mp.create_mas_destination('maslocal2', 'localhost')
41+
dest = mp.create_mas_destination('sasctlmas', 'localhost')
4242

43-
assert dest.name == 'maslocal2'
43+
assert dest.name == 'sasctlmas'
4444
assert dest.destinationType == 'microAnalyticService'
4545
assert 'description' not in dest

tests/integration/test_pymas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,6 @@ def test_publish_and_execute(tmpdir):
279279
result = mas.execute_module_step('sasctl_test', 'score', **x1)
280280

281281
assert result['rc'] == 0
282-
assert result['var1'] == 24
282+
assert round(result['var1'], 2) == 30.29
283283
assert result['msg'] is None
284284

tests/unit/test_tasks.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# SPDX-License-Identifier: Apache-2.0
66

77
import pytest
8+
from six.moves import mock
9+
10+
from sasctl.core import RestObj
811

912

1013
def test_sklearn_metadata():
@@ -43,7 +46,6 @@ def test_sklearn_metadata():
4346

4447

4548
def test_parse_module_url():
46-
from sasctl.core import RestObj
4749
from sasctl.tasks import _parse_module_url
4850

4951
body = RestObj({'createdBy': 'sasdemo',
@@ -69,4 +71,30 @@ def test_parse_module_url():
6971
'version': 1})
7072

7173
msg = body.get('log').lstrip('SUCßCESS===')
72-
assert _parse_module_url(msg) == '/microanalyticScore/modules/decisiontree'
74+
assert _parse_module_url(msg) == '/microanalyticScore/modules/decisiontree'
75+
76+
77+
def test_save_performance_project_types():
78+
from sasctl.tasks import update_performance
79+
80+
with mock.patch('sasctl._services.model_repository.ModelRepository''.get_model') as model:
81+
with mock.patch('sasctl._services.model_repository.ModelRepository.get_project') as project:
82+
model.return_value = RestObj(name='fakemodel', projectId=1)
83+
84+
# Function is required
85+
with pytest.raises(ValueError):
86+
project.return_value = {}
87+
update_performance(None, None, None)
88+
89+
# Target Level is required
90+
with pytest.raises(ValueError):
91+
project.return_value = {'function': 'Prediction'}
92+
update_performance(None, None, None)
93+
94+
# Prediction variable required
95+
with pytest.raises(ValueError):
96+
project.return_value = {'function': 'Prediction',
97+
'targetLevel': 'Binary'}
98+
update_performance(None, None, None)
99+
100+
# Check projects w/ invalid properties

0 commit comments

Comments
 (0)