Skip to content

Commit

Permalink
fix: edit the job context and batch doc comments (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyecusch authored Oct 16, 2024
1 parent 44fb8ed commit 8d7ef2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions nitric/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ async def chained_middleware(ctx: C, nxt: Optional[Middleware[C]] = None) -> C:


class JobRequest:
"""Represents a translated Job, from a Job Definition, forwarded from the Nitric Runtime Server."""
"""Represents a job task forwarded from the Nitric Runtime Server."""

data: dict[str, Any]

Expand All @@ -379,28 +379,28 @@ def __init__(self, data: dict[str, Any]):


class JobResponse:
"""Represents the response to a trigger from a Job submission as a result of a SubmitJob call."""
"""Represents the response to a job task, indicating the result."""

def __init__(self, success: bool = True):
"""Construct a new EventResponse."""
self.success = success


class JobContext:
"""Represents the full request/response context for an Event based trigger."""
"""Represents the full request/response context for a Job task trigger."""

def __init__(self, request: JobRequest, response: Optional[JobResponse] = None):
"""Construct a new EventContext."""
"""Construct a new JobContext."""
self.req = request
self.res = response if response else JobResponse()

@staticmethod
def _from_request(msg: BatchServerMessage) -> "JobContext":
"""Construct a new EventContext from a Topic trigger from the Nitric Membrane."""
"""Construct a new JobContext from a Job trigger from the Nitric Server."""
return JobContext(request=JobRequest(data=dict_from_struct(msg.job_request.data.struct)))

def to_response(self) -> BatchClientMessage:
"""Construct a EventContext for the Nitric Membrane from this context object."""
"""Construct a JobContext for the Nitric Server from this context object."""
return BatchClientMessage(job_response=BatchJobResponse(success=self.res.success))


Expand Down
4 changes: 2 additions & 2 deletions nitric/resources/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
memory: int | None = None,
gpus: int | None = None,
):
"""Construct a new WebsocketHandler."""
"""Construct a new JobHandler."""
self._handler = handler
self._responses = AsyncNotifierList()
self._registration_request = RegistrationRequest(
Expand All @@ -70,7 +70,7 @@ async def _message_request_iterator(self):
yield response

async def start(self) -> None:
"""Register this subscriber and listen for messages."""
"""Register this job handler and listen for tasks."""
channel = ChannelManager.get_channel()
server = JobStub(channel=channel)

Expand Down

0 comments on commit 8d7ef2b

Please sign in to comment.