Skip to content

Commit

Permalink
Add kernel output types for use in papermill-origami and release 0.0.5 (
Browse files Browse the repository at this point in the history
#40)

* Add kernel output types

* Add changelog

* Bump version: 0.0.4 → 0.0.5
  • Loading branch information
rohitsanj authored Sep 13, 2022
1 parent 2b7cc34 commit 5c1d602
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.4
current_version = 0.0.5
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize =
{major}.{minor}.{patch}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.0.5] - 2022-09-13
### Added
- Add kernel output types for papermill-origami

## [0.0.4] - 2022-09-09
### Added
- Support loading JWT token from `NOTEABLE_TOKEN` environment variable.
Expand Down
2 changes: 1 addition & 1 deletion origami/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.0.4"
version = "0.0.5"
52 changes: 52 additions & 0 deletions origami/types/rtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,58 @@ class CellStateMessageReply(GenericRTUReplySchema[CellStateMessageData]):
event = 'cell_state_update_event'


class KernelOutputType(enum.Enum):
def _generate_next_value_(name, start, count, last_values):
return name

execute_result = enum.auto()
stream = enum.auto()
display_data = enum.auto()
error = enum.auto()
clear_output = enum.auto()
update_display_data = enum.auto()


class KernelOutputContent(BaseModel):
raw: Optional[str] = None
url: Optional[str] = None
mimetype: str


class KernelOutput(NoteableAPIModel):
type: KernelOutputType
display_id: Optional[str]
available_mimetypes: List[str]
content_metadata: KernelOutputContent
content: Optional[KernelOutputContent]
parent_collection_id: UUID

class Config:
arbitrary_types_allowed = True


class KernelOutputCollection(NoteableAPIModel):
cell_id: Optional[str] = None
widget_model_id: Optional[str] = None
file_id: UUID
outputs: List[KernelOutput]

@root_validator
def has_cell_or_model_id(cls, values):
assert any(
[values.get("cell_id") is not None, values.get("widget_model_id") is not None]
), "collection must contain either cell id or model id"
assert not all(
[values.get("cell_id") is not None, values.get("widget_model_id") is not None]
), "collection must contain either cell id or model id, not both"
return values


UpdateOutputCollectionEventSchema = GenericRTUReplySchema[KernelOutputCollection]

AppendOutputEventSchema = GenericRTUReplySchema[KernelOutput]


@enum.unique
class KernelStatus(enum.Enum):
"""The enumerable defining all the possible kernel states one can land in.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[tool.poetry]
name = "noteable-origami"
version = "0.0.4"
version = "0.0.5"
description = "The Noteable API interface"
authors = ["Matt Seal <[email protected]>"]
maintainers = ["Matt Seal <[email protected]>"]
Expand Down

0 comments on commit 5c1d602

Please sign in to comment.