Skip to content

Commit

Permalink
Improve docstring/fix cross-refs in docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Sep 22, 2024
1 parent e1030f0 commit 8fe7f95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions py/client/pydeephaven/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def bind_table(self, name: str, table: Table) -> None:
def publish(self, source_ticket: Ticket, result_ticket: Ticket) -> None:
""" Publishes a source ticket to the result ticket.
This is low-level method that should be used mostly to publish non-Table server objects that are previously
This is low-level method that can be used to publish non-Table server objects that are previously
fetched from the server. The source ticket represents the previously fetched server object to be published, and
the result ticket, which should normally be a SharedTicket, is the ticket to publish to. The result ticket can
then be fetched by other sessions to access the object as long as the object is not released. This method is
Expand All @@ -569,8 +569,8 @@ def publish(self, source_ticket: Ticket, result_ticket: Ticket) -> None:
def fetch(self, ticket: Ticket) -> ExportTicket:
"""Fetches a server object by ticket.
This is low-level method that should be used mostly to fetch non-Table server objects from the server. The ticket
represents a fetchable server object, e.g :class:`plugin_client.PluginClient`, :class:`plugin_client.Fetchable`.
This is low-level method that can be used to fetch non-Table server objects. The ticket represents a
fetchable server object, e.g :class:`~.plugin_client.PluginClient`, :class:`~.plugin_client.Fetchable`.
This method is used together with the :meth:`.publish` method to share server objects between sessions.
Args:
Expand Down Expand Up @@ -600,7 +600,7 @@ def publish_table(self, ticket: SharedTicket, table: Table) -> None:
Raises:
DHError
"""
self.publish(table, ticket)
self.publish(table.ticket, ticket)

def fetch_table(self, ticket: SharedTicket) -> Table:
"""Fetches a table by ticket.
Expand Down
14 changes: 11 additions & 3 deletions py/client/pydeephaven/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class ExportTicket(Ticket):
"""An ExportTicket is a ticket that references an object exported from the server such as a table or a plugin widget.
An exported server object will remain available on the server until the ticket is released or the session is
closed. Many types of server objects are exportable and can be fetched to the client as an export ticket or as an
instance of wrapper class (such as :class:`table.Table`, :class:`plugin_client.PluginClient`, etc.) that wraps the
instance of wrapper class (such as :class:`~.table.Table`, :class:`~.plugin_client.PluginClient`, etc.) that wraps the
export ticket. An export ticket can be published to a :class:`.SharedTicket` so that the exported server object can
be shared with other sessions.
Note: Users should not create ExportTickets directly. They are managed by the Session and are automatically created
when exporting objects from the server via. :meth:`.Session.open_table`, :meth:`.Session.fetch`, and any operations
that returns a Table.
that return a Table.
"""

def __init__(self, ticket_bytes: bytes):
Expand Down Expand Up @@ -100,7 +100,7 @@ def export_ticket(cls, ticket_no: int) -> ExportTicket:
class ScopeTicket(Ticket):
"""A ScopeTicket is a ticket that references a scope variable on the server. Scope variables are variables in the global
scope of the server and are accessible to all sessions. Scope variables can be fetched to the client as an export
ticket or a Deephaven :class:`table.Table` that wraps the export ticket. """
ticket or a Deephaven :class:`~.table.Table` that wraps the export ticket. """

def __init__(self, ticket_bytes: bytes):
"""Initializes a ScopeTicket.
Expand All @@ -125,6 +125,9 @@ def scope_ticket(cls, name: str) -> ScopeTicket:
Returns:
a ScopeTicket
"""
if not name:
raise DHError('scope_ticket: name must be a non-empty string')

return cls(ticket_bytes=f's/{name}'.encode(encoding='ascii'))


Expand Down Expand Up @@ -161,6 +164,11 @@ def app_ticket(cls, app_id: str, field: str) -> ApplicationTicket:
Returns:
an ApplicationTicket
"""
if not app_id:
raise DHError('app_ticket: app_id must be a non-empty string')
if not field:
raise DHError('app_ticket: field must be a non-empty string')

return cls(ticket_bytes=f'a/{app_id}/{field}'.encode(encoding='ascii'))


Expand Down

0 comments on commit 8fe7f95

Please sign in to comment.