Skip to content

Conversation

@jdbeel
Copy link
Contributor

@jdbeel jdbeel commented Jan 27, 2026

No description provided.

Copy link
Contributor

@dmaze dmaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see room for other clients besides the direct client to support this.

If it's not hard, the counterpart to this is creating a trainee from bytes (HowsoDirectClient.create_trainee_from_memory()) and it might be nice to see higher-level support for that too. This should let you round-trip a trainee by dumping it to memory (and deleting it it you want) and then reloading it.

The Trainee file data as bytes. Or None if the `trainee_id` and/or `trainee_path` does not refer to
a valid Trainee.
"""
if not isinstance(self.client, HowsoDirectClient):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might prefer to condition this on the existence of the trainee_to_memory method, or use a runtime-checkable protocol.

@runtime_checkable
class CanLoadSaveMemory(Protocol):
  def trainee_to_memory(self, id: str, file_type: Literal["amlg", "caml"], trainee_path: something) -> bytes | None: ...

if isinstance(self.client, CanLoadSaveMemory):
  return self.client.trainee_to_memory(...)
raise NotImplementedError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants