Skip to content

Commit

Permalink
docs: adds additional docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein committed Apr 26, 2024
1 parent 9230d94 commit 780ca20
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,18 @@ def delete(self) -> None:
def deploy(self) -> tasks.Task:
"""Deploy the content.
Spawns an asynchronous task, which activates the latest bundle.
Returns
-------
tasks.Task
The task for the deployment.
Examples
--------
>>> task = content.deploy()
>>> task.wait_for()
None
"""
path = f"v1/content/{self.guid}/deploy"
url = urls.append(self.config.url, path)
Expand Down
34 changes: 33 additions & 1 deletion src/posit/connect/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,29 @@ def update(self, *args, **kwargs) -> None:
...

def update(self, *args, **kwargs) -> None:
"""Update the task."""
"""Update the task.
See Also
--------
task.wait_for : Wait for the task to complete.
Notes
-----
When waiting for a task to complete, one should consider utilizing `task.wait_for`.
Examples
--------
>>> task.output
[
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
]
>>> task.update()
>>> task.output
[
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"Pretium aenean pharetra magna ac placerat vestibulum lectus mauris."
]
"""
params = dict(*args, **kwargs)
path = f"v1/tasks/{self.id}"
url = urls.append(self.config.url, path)
Expand All @@ -113,6 +135,16 @@ def wait_for(self, sleep: int = 1) -> None:
----------
sleep : int, optional
Maximum number of seconds to wait between status checks.
Examples
--------
>>> task = tasks.get(task_id)
>>> task.wait_for()
None
>>> task tasks.get(task_id)
>>> task.wait_for(5) # wait five seconds between status checks
None
"""
while not self.is_finished:
self.update(wait=sleep)
Expand Down

0 comments on commit 780ca20

Please sign in to comment.