Skip to content

documentation: fix minor misses from the remote function doc release #3813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/remote_function/sagemaker.remote_function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Remote function classes and methods specification
.. automethod:: sagemaker.remote_function.client.remote


RemoteExcutor
-------------
RemoteExecutor
--------------

.. autoclass:: sagemaker.remote_function.RemoteExecutor
:members:
Expand Down
54 changes: 34 additions & 20 deletions src/sagemaker/remote_function/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def remote(
This decorator wraps the annotated code and runs it as a new SageMaker job synchronously
with the provided runtime settings.

Unless mentioned otherwise, the decorator first looks up the value from the SageMaker
If a parameter value is not set, the decorator first looks up the value from the SageMaker
configuration file. If no value is specified in the configuration file or no configuration file
is found, the decorator selects the default as specified below. For more information, see
`Configuring and using defaults with the SageMaker Python SDK <https://sagemaker.readthedocs.io/
Expand Down Expand Up @@ -131,7 +131,7 @@ def remote(
annotated with the remote decorator is invoked using the Python runtime available
in the system path.

* The parameter dependencies is set to auto_capture. SageMaker will automatically
* The parameter dependencies is set to ``auto_capture``. SageMaker will automatically
generate an env_snapshot.yml corresponding to the current active conda environment’s
snapshot. You do not need to provide a dependencies file. The following conditions
apply:
Expand Down Expand Up @@ -204,7 +204,7 @@ def remote(
downloaded in the previous runs.

max_retry_attempts (int): The max number of times the job is retried on
```InternalServerFailure``` Error from SageMaker service. Defaults to 1.
``InternalServerFailure`` Error from SageMaker service. Defaults to 1.

max_runtime_in_seconds (int): The upper limit in seconds to be used for training. After
this specified amount of time, SageMaker terminates the job regardless of its current
Expand Down Expand Up @@ -475,10 +475,10 @@ def __init__(
):
"""Constructor for RemoteExecutor

Unless mentioned otherwise, the constructor first looks up the value from the SageMaker
configuration file. If no value is specified in the configuration file or no configuration
file is found, the constructor selects the default as specified below. For more
information, see `Configuring and using defaults with the SageMaker Python SDK
If a parameter value is not set, the constructor first looks up the value from the
SageMaker configuration file. If no value is specified in the configuration file or
no configuration file is found, the constructor selects the default as specified below.
For more information, see `Configuring and using defaults with the SageMaker Python SDK
<https://sagemaker.readthedocs.io/en/stable/overview.html
#configuring-and-using-defaults-with-the-sagemaker-python-sdk>`_.

Expand Down Expand Up @@ -520,7 +520,7 @@ def __init__(
annotated with the remote decorator is invoked using the Python runtime available
in the system path.

* The parameter dependencies is set to auto_capture. SageMaker will automatically
* The parameter dependencies is set to ``auto_capture``. SageMaker will automatically
generate an env_snapshot.yml corresponding to the current active conda environment’s
snapshot. You do not need to provide a dependencies file. The following conditions
apply:
Expand Down Expand Up @@ -595,7 +595,7 @@ def __init__(
max_parallel_jobs (int): Maximum number of jobs that run in parallel. Defaults to 1.

max_retry_attempts (int): The max number of times the job is retried on
```InternalServerFailure``` Error from SageMaker service. Defaults to 1.
``InternalServerFailure`` Error from SageMaker service. Defaults to 1.

max_runtime_in_seconds (int): The upper limit in seconds to be used for training. After
this specified amount of time, SageMaker terminates the job regardless of its current
Expand Down Expand Up @@ -1012,7 +1012,8 @@ def wait(
timeout (int): Timeout in seconds to wait until the job is completed before it is
stopped. Defaults to ``None``.

Returns: None
Returns:
None
"""

with self._condition:
Expand All @@ -1022,14 +1023,15 @@ def wait(
if self._state == _RUNNING:
self._job.wait(timeout=timeout)

def cancel(self):
def cancel(self) -> bool:
"""Cancel the function execution.

This method prevents the SageMaker job being created or stops the underlying SageMaker job
early if it is already in progress.

Returns: ``True`` if the underlying SageMaker job created as a result of the remote function
run is cancelled.
Returns:
``True`` if the underlying SageMaker job created as a result of the remote function
run is cancelled.
"""
with self._condition:
if self._state == _FINISHED:
Expand All @@ -1042,18 +1044,30 @@ def cancel(self):
self._state = _CANCELLED
return True

def running(self):
"""Returns ``True`` if the underlying sagemaker job is still running."""
def running(self) -> bool:
"""Check if the underlying SageMaker job is running.

Returns:
``True`` if the underlying SageMaker job is still running. ``False``, otherwise.
"""
with self._condition:
return self._state == _RUNNING

def cancelled(self):
"""Returns ``True`` if the underlying sagemaker job was cancelled. ``False``, otherwise."""
def cancelled(self) -> bool:
"""Check if the underlying SageMaker job was cancelled.

Returns:
``True`` if the underlying SageMaker job was cancelled. ``False``, otherwise.
"""
with self._condition:
return self._state == _CANCELLED

def done(self):
"""Returns ``True`` if the underlying sagemaker job finished running."""
def done(self) -> bool:
"""Check if the underlying SageMaker job is finished.

Returns:
``True`` if the underlying SageMaker job finished running. ``False``, otherwise.
"""
with self._condition:
if self._state == _RUNNING and self._job.describe()["TrainingJobStatus"] in [
"Completed",
Expand All @@ -1068,7 +1082,7 @@ def done(self):
return False


def get_future(job_name, sagemaker_session=None):
def get_future(job_name, sagemaker_session=None) -> Future:
"""Get a future object with information about a job with the given job_name.

Args:
Expand Down