Skip to content

Commit 97c057d

Browse files
committed
remove six dependencies
1 parent 267e16c commit 97c057d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2188
-1720
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ sasctl folders list
5252
sasctl requires the following Python packages be installed.
5353
If not already present, these packages will be downloaded and installed automatically.
5454
- requests
55-
- six
56-
- futures (Python 2.7 only)
55+
- pyyaml
5756

5857
The following additional packages are recommended for full functionality:
5958
- swat

doc/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ Prerequisites
3131
If not already present, these packages will be downloaded and install automatically.
3232

3333
- requests
34-
- six
35-
- futures (Python 2.7 only)
34+
- pyyaml
3635

3736
The following additional packages are recommended for full functionality:
3837

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def get_file(filename):
4646
'pandas',
4747
'scikit-learn',
4848
'requests',
49-
'six >= 1.11',
5049
'pyyaml',
5150
'packaging'
5251
],

src/sasctl/_services/concepts.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,30 @@
1111
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
1212
# SPDX-License-Identifier: Apache-2.0
1313

14-
import six
15-
1614
from .service import Service
1715
from ..core import uri_as_str
1816

17+
1918
class Concepts(Service):
2019
"""Assigns concepts to natural language text documents according to a
2120
prebuilt or user-defined model.
2221
"""
2322

2423
_SERVICE_ROOT = '/concepts'
2524

26-
def assign_concepts(self,
27-
documents,
28-
caslib=None,
29-
id_column=None,
30-
text_column=None,
31-
description=None,
32-
model=None,
33-
output_postfix=None,
34-
match_type=None,
35-
enable_facts=False,
36-
language='en'):
25+
def assign_concepts(
26+
self,
27+
documents,
28+
caslib=None,
29+
id_column=None,
30+
text_column=None,
31+
description=None,
32+
model=None,
33+
output_postfix=None,
34+
match_type=None,
35+
enable_facts=False,
36+
language='en',
37+
):
3738
"""Performs sentiment analysis on the input data.
3839
3940
Creates a setiment analysis task that executes asynchronously. There
@@ -84,28 +85,30 @@ def assign_concepts(self,
8485
if documents is None:
8586
raise TypeError('`documents` cannot be None.')
8687

87-
if isinstance(documents, (dict, six.string_types)):
88+
if isinstance(documents, (dict, str)):
8889
data = {
8990
'inputUri': uri_as_str(documents),
9091
'documentIdVariable': id_column,
9192
'textVariable': text_column,
92-
'version': 1
93+
'version': 1,
9394
}
9495
else:
9596
data = {
9697
'caslibUri': uri_as_str(caslib),
9798
'documents': documents,
98-
'version': 1
99+
'version': 1,
99100
}
100101

101-
data.update({
102-
'description': description,
103-
'language': language,
104-
'modelUri': uri_as_str(model),
105-
'outputTableNamePostfix': output_postfix,
106-
'matchType': match_type,
107-
'enableFacts': enable_facts
108-
})
102+
data.update(
103+
{
104+
'description': description,
105+
'language': language,
106+
'modelUri': uri_as_str(model),
107+
'outputTableNamePostfix': output_postfix,
108+
'matchType': match_type,
109+
'enableFacts': enable_facts,
110+
}
111+
)
109112

110113
# Optional fields are not ignored if None. Explicitly remove before sending
111114
for k in list(data.keys()):
@@ -118,15 +121,13 @@ def assign_concepts(self,
118121
if 'documents' in data:
119122
url += '#data'
120123
headers = {
121-
'Content-Type':
122-
'application/vnd.sas.text.concepts.job.request.documents+json',
123-
'Accept': 'application/vnd.sas.text.concepts.job+json'
124+
'Content-Type': 'application/vnd.sas.text.concepts.job.request.documents+json',
125+
'Accept': 'application/vnd.sas.text.concepts.job+json',
124126
}
125127
else:
126128
headers = {
127-
'Content-Type':
128-
'application/vnd.sas.text.concepts.job.request+json',
129-
'Accept': 'application/vnd.sas.text.concepts.job+json'
129+
'Content-Type': 'application/vnd.sas.text.concepts.job.request+json',
130+
'Accept': 'application/vnd.sas.text.concepts.job+json',
130131
}
131132

132133
return self.post(url, json=data, headers=headers)

src/sasctl/_services/files.py

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

77
import os
8-
import six
98

109
from .folders import Folders
1110
from .service import Service
@@ -29,8 +28,9 @@ class Files(Service):
2928

3029
_SERVICE_ROOT = '/files'
3130

32-
list_files, get_file, update_file, \
33-
delete_file = Service._crud_funcs('/files', 'file')
31+
list_files, get_file, update_file, delete_file = Service._crud_funcs(
32+
'/files', 'file'
33+
)
3434

3535
@sasctl_command('files', 'create')
3636
def create_file(self, file, folder=None, filename=None, expiration=None):
@@ -53,14 +53,16 @@ def create_file(self, file, folder=None, filename=None, expiration=None):
5353
A dictionary containing the file attributes.
5454
5555
"""
56-
if isinstance(file, six.string_types):
56+
if isinstance(file, str):
5757
filename = filename or os.path.splitext(os.path.split(file)[1])[0]
5858

5959
with open(file, 'rb') as f:
6060
file = f.read()
6161
else:
6262
if filename is None:
63-
raise ValueError('`filename` must be specified if `file` is not a path.')
63+
raise ValueError(
64+
'`filename` must be specified if `file` is not a path.'
65+
)
6466

6567
file = file.read()
6668

@@ -78,8 +80,9 @@ def create_file(self, file, folder=None, filename=None, expiration=None):
7880
pass
7981
# TODO: add 'expirationTimeStamp' to params. Need to determine correct format
8082

81-
return self.post('/files#multipartUpload',
82-
files={filename: file}, params=params)
83+
return self.post(
84+
'/files#multipartUpload', files={filename: file}, params=params
85+
)
8386

8487
@sasctl_command('files', 'content')
8588
def get_file_content(self, file):

src/sasctl/_services/microanalytic_score.py

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from collections import OrderedDict
1111
from math import isnan
1212

13-
import six
14-
1513
from .service import Service
1614

1715

@@ -46,8 +44,9 @@ def is_uuid(cls, id_):
4644
# MAS id.
4745
return re.match('^[_a-z][_a-z0-9]+$', id_) is not None
4846

49-
list_modules, get_module, update_module, \
50-
delete_module = Service._crud_funcs('/modules', 'module')
47+
list_modules, get_module, update_module, delete_module = Service._crud_funcs(
48+
'/modules', 'module'
49+
)
5150

5251
def get_module_step(self, module, step):
5352
"""Details of a single step in a given module.
@@ -129,8 +128,7 @@ def execute_module_step(self, module, step, return_dict=True, **kwargs):
129128
elif type_name == 'int64':
130129
kwargs[k] = int(kwargs[k])
131130

132-
body = {'inputs': [{'name': k, 'value': v}
133-
for k, v in six.iteritems(kwargs)]}
131+
body = {'inputs': [{'name': k, 'value': v} for k, v in kwargs.items()]}
134132

135133
# Convert NaN to None (null) before calling MAS
136134
for i in body['inputs']:
@@ -163,8 +161,14 @@ def execute_module_step(self, module, step, return_dict=True, **kwargs):
163161
return outputs[0]
164162
return outputs
165163

166-
def create_module(self, name=None, description=None, source=None,
167-
language='python', scope='public'):
164+
def create_module(
165+
self,
166+
name=None,
167+
description=None,
168+
source=None,
169+
language='python',
170+
scope='public',
171+
):
168172
"""Create a new module in MAS.
169173
170174
Parameters
@@ -189,14 +193,15 @@ def create_module(self, name=None, description=None, source=None,
189193
elif language == 'ds2':
190194
t = 'text/vnd.sas.source.ds2'
191195
else:
192-
raise ValueError('Unrecognized source code language `%s`.'
193-
% language)
196+
raise ValueError('Unrecognized source code language `%s`.' % language)
194197

195-
data = {'id': name,
196-
'type': t,
197-
'description': description,
198-
'source': source,
199-
'scope': scope}
198+
data = {
199+
'id': name,
200+
'type': t,
201+
'description': description,
202+
'source': source,
203+
'scope': scope,
204+
}
200205

201206
r = self.post('/modules', json=data)
202207
return r
@@ -240,8 +245,7 @@ def define_steps(self, module):
240245
# Default all params to None to allow method(DataFrame) execution
241246
input_params = [a for a in arguments] + ['**kwargs']
242247
method_name = '_%s_%s' % (module.id, step.id)
243-
signature = 'def %s(%s):' \
244-
% (method_name, ', '.join(input_params))
248+
signature = 'def %s(%s):' % (method_name, ', '.join(input_params))
245249

246250
# If the module step takes arguments, then we perform a number
247251
# of additional checks to make the allowed input as wide as possible
@@ -266,20 +270,22 @@ def define_steps(self, module):
266270
' is_numpy = False',
267271
'if is_pandas:',
268272
' assert len(first_input.shape) == 1',
269-
' for k in first_input.keys():'
273+
' for k in first_input.keys():',
270274
]
271275

272276
for arg in arguments:
273277
arg_checks.append(" if k.lower() == '%s':" % arg.lower())
274278
arg_checks.append(" %s = first_input[k]" % arg)
275279
arg_checks.append(" continue")
276280

277-
arg_checks.extend([
278-
'elif is_numpy:',
279-
' if len(first_input.shape) > 1:',
280-
' assert first_input.shape[0] == 1',
281-
' first_input = first_input.ravel()'
282-
])
281+
arg_checks.extend(
282+
[
283+
'elif is_numpy:',
284+
' if len(first_input.shape) > 1:',
285+
' assert first_input.shape[0] == 1',
286+
' first_input = first_input.ravel()',
287+
]
288+
)
283289

284290
for i, arg in enumerate(arguments):
285291
arg_checks.append(' %s = first_input[%d]' % (arg, i))
@@ -307,31 +313,38 @@ def define_steps(self, module):
307313

308314
# Full method source code
309315
# Drops 'rc' and 'msg' from return values
310-
code = (signature,
311-
type_string,
312-
' """Execute step \'%s\' of module \'%s\'."""' % (step, module),
313-
'\n'.join(' %s' % a for a in arg_checks),
314-
' r = execute_module_step(%s)' % ', '.join(['module', 'step'] + call_params),
315-
' r.pop("rc", None)',
316-
' r.pop("msg", None)',
317-
' if len(r) == 1:',
318-
' return r.popitem()[1]',
319-
' return tuple(v for v in r.values())'
320-
)
316+
code = (
317+
signature,
318+
type_string,
319+
' """Execute step \'%s\' of module \'%s\'."""' % (step, module),
320+
'\n'.join(' %s' % a for a in arg_checks),
321+
' r = execute_module_step(%s)'
322+
% ', '.join(['module', 'step'] + call_params),
323+
' r.pop("rc", None)',
324+
' r.pop("msg", None)',
325+
' if len(r) == 1:',
326+
' return r.popitem()[1]',
327+
' return tuple(v for v in r.values())',
328+
)
321329

322330
code = '\n'.join(code)
323-
self.log.debug("Generated code for step '%s' of module '%s':\n%s",
324-
id_, module, code)
331+
self.log.debug(
332+
"Generated code for step '%s' of module '%s':\n%s", id_, module, code
333+
)
325334
compiled = compile(code, '<string>', 'exec')
326335

327336
env = globals().copy()
328-
env.update({'execute_module_step': self.execute_module_step,
329-
'module': module,
330-
'step': step})
331-
332-
func = types.FunctionType(compiled.co_consts[0],
333-
env,
334-
argdefs=tuple(None for x in arguments))
337+
env.update(
338+
{
339+
'execute_module_step': self.execute_module_step,
340+
'module': module,
341+
'step': step,
342+
}
343+
)
344+
345+
func = types.FunctionType(
346+
compiled.co_consts[0], env, argdefs=tuple(None for x in arguments)
347+
)
335348

336349
setattr(module, step.id, func)
337350

0 commit comments

Comments
 (0)