Skip to content

Commit 55b4a07

Browse files
committed
googledatalab#711 Fix Incompatibility with Python 3.7
1 parent 8c2df84 commit 55b4a07

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

datalab/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
"""Google Cloud Platform library - Internal Helpers."""
1414

15-
from ._async import async, async_function, async_method
15+
from ._async import asynchron, async_function, async_method
1616
from ._gcp_job import GCPJob
1717
from ._http import Http, RequestException
1818
from ._iterator import Iterator
@@ -24,7 +24,7 @@
2424
from ._utils import print_exception_with_last_stack, get_item, compare_datetimes, \
2525
pick_unused_port, is_http_running_on, gcs_copy_file
2626

27-
__all__ = ['async', 'async_function', 'async_method', 'GCPJob', 'Http', 'RequestException',
27+
__all__ = ['asynchron', 'async_function', 'async_method', 'GCPJob', 'Http', 'RequestException',
2828
'Iterator', 'Job', 'JobError', 'JSONEncoder', 'LRUCache', 'LambdaJob', 'DataflowJob',
2929
'print_exception_with_last_stack', 'get_item', 'compare_datetimes', 'pick_unused_port',
3030
'is_http_running_on', 'gcs_copy_file']

datalab/utils/_async.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from future.utils import with_metaclass
2424

2525

26-
class async(with_metaclass(abc.ABCMeta, object)):
26+
class asynchron(with_metaclass(abc.ABCMeta, object)):
2727
""" Base class for async_function/async_method. Creates a wrapped function/method that will
2828
run the original function/method on a thread pool worker thread and return a Job instance
2929
for monitoring the status of the thread.
@@ -55,27 +55,27 @@ def __call__(self, *args, **kwargs):
5555
return _job.Job(future=self.executor.submit(self._call, *args, **kwargs))
5656

5757

58-
class async_function(async):
58+
class async_function(asynchron):
5959
""" This decorator can be applied to any static function that makes blocking calls to create
6060
a modified version that creates a Job and returns immediately; the original
6161
method will be called on a thread pool worker thread.
6262
"""
6363

6464
def _call(self, *args, **kwargs):
6565
# Call the wrapped method.
66-
return self._function(*async._preprocess_args(*args), **async._preprocess_kwargs(**kwargs))
66+
return self._function(*asynchron._preprocess_args(*args), **asynchron._preprocess_kwargs(**kwargs))
6767

6868

69-
class async_method(async):
69+
class async_method(asynchron):
7070
""" This decorator can be applied to any class instance method that makes blocking calls to create
7171
a modified version that creates a Job and returns immediately; the original method will be
7272
called on a thread pool worker thread.
7373
"""
7474

7575
def _call(self, *args, **kwargs):
7676
# Call the wrapped method.
77-
return self._function(self.obj, *async._preprocess_args(*args),
78-
**async._preprocess_kwargs(**kwargs))
77+
return self._function(self.obj, *asynchron._preprocess_args(*args),
78+
**asynchron._preprocess_kwargs(**kwargs))
7979

8080
def __get__(self, instance, owner):
8181
# This is important for attribute inheritance and setting self.obj so it can be

datalab/utils/_lambda_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, fn, job_id, *args, **kwargs):
3030
job_id: an optional ID for the job. If None, a UUID will be generated.
3131
"""
3232
super(LambdaJob, self).__init__(job_id)
33-
self._future = _async.async.executor.submit(fn, *args, **kwargs)
33+
self._future = _async.asynchron.executor.submit(fn, *args, **kwargs)
3434

3535
def __repr__(self):
3636
"""Returns a representation for the job for showing in the notebook.

datalab/utils/commands/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def parse_config(config, env, as_dict=True):
324324
elif stripped[0] == '{':
325325
config = json.loads(config)
326326
else:
327-
config = yaml.load(config)
327+
config = yaml.load(config, Loader=yaml.FullLoader)
328328
if as_dict:
329329
config = dict(config)
330330

google/datalab/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
"""Google Cloud Platform library - Internal Helpers."""
1414

15-
from ._async import async, async_function, async_method
15+
from ._async import asynchron, async_function, async_method
1616
from ._http import Http, RequestException
1717
from ._iterator import Iterator
1818
from ._json_encoder import JSONEncoder
@@ -23,7 +23,7 @@
2323
pick_unused_port, is_http_running_on, gcs_copy_file, python_portable_string
2424

2525

26-
__all__ = ['async', 'async_function', 'async_method', 'Http', 'RequestException', 'Iterator',
26+
__all__ = ['asynchron', 'async_function', 'async_method', 'Http', 'RequestException', 'Iterator',
2727
'JSONEncoder', 'LRUCache', 'LambdaJob', 'DataflowJob',
2828
'print_exception_with_last_stack', 'get_item', 'compare_datetimes', 'pick_unused_port',
2929
'is_http_running_on', 'gcs_copy_file', 'python_portable_string']

google/datalab/utils/_async.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from future.utils import with_metaclass
2424

2525

26-
class async(with_metaclass(abc.ABCMeta, object)):
26+
class asynchron(with_metaclass(abc.ABCMeta, object)):
2727
""" Base class for async_function/async_method. Creates a wrapped function/method that will
2828
run the original function/method on a thread pool worker thread and return a Job instance
2929
for monitoring the status of the thread.
@@ -55,27 +55,27 @@ def __call__(self, *args, **kwargs):
5555
return Job(future=self.executor.submit(self._call, *args, **kwargs))
5656

5757

58-
class async_function(async):
58+
class async_function(asynchron):
5959
""" This decorator can be applied to any static function that makes blocking calls to create
6060
a modified version that creates a Job and returns immediately; the original
6161
method will be called on a thread pool worker thread.
6262
"""
6363

6464
def _call(self, *args, **kwargs):
6565
# Call the wrapped method.
66-
return self._function(*async._preprocess_args(*args), **async._preprocess_kwargs(**kwargs))
66+
return self._function(*asynchron._preprocess_args(*args), **asynchron._preprocess_kwargs(**kwargs))
6767

6868

69-
class async_method(async):
69+
class async_method(asynchron):
7070
""" This decorator can be applied to any class instance method that makes blocking calls to create
7171
a modified version that creates a Job and returns immediately; the original method will be
7272
called on a thread pool worker thread.
7373
"""
7474

7575
def _call(self, *args, **kwargs):
7676
# Call the wrapped method.
77-
return self._function(self.obj, *async._preprocess_args(*args),
78-
**async._preprocess_kwargs(**kwargs))
77+
return self._function(self.obj, *asynchron._preprocess_args(*args),
78+
**asynchron._preprocess_kwargs(**kwargs))
7979

8080
def __get__(self, instance, owner):
8181
# This is important for attribute inheritance and setting self.obj so it can be

google/datalab/utils/_lambda_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, fn, job_id, *args, **kwargs):
3030
job_id: an optional ID for the job. If None, a UUID will be generated.
3131
"""
3232
super(LambdaJob, self).__init__(job_id)
33-
self._future = _async.async.executor.submit(fn, *args, **kwargs)
33+
self._future = _async.asynchron.executor.submit(fn, *args, **kwargs)
3434

3535
def __repr__(self):
3636
"""Returns a representation for the job for showing in the notebook.

google/datalab/utils/commands/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def parse_config(config, env, as_dict=True):
329329
elif stripped[0] == '{':
330330
config = json.loads(config)
331331
else:
332-
config = yaml.load(config)
332+
config = yaml.load(config, Loader=yaml.FullLoader)
333333
if as_dict:
334334
config = dict(config)
335335

@@ -374,7 +374,7 @@ def parse_config_for_selected_keys(content, keys):
374374
elif stripped[0] == '{':
375375
config = json.loads(content)
376376
else:
377-
config = yaml.load(content)
377+
config = yaml.load(content, Loader=yaml.FullLoader)
378378

379379
if not isinstance(config, dict):
380380
raise ValueError('Invalid config.')

0 commit comments

Comments
 (0)