Skip to content

Commit

Permalink
Update SDK to version 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Roboto-Bot-O committed Nov 11, 2024
1 parent b42d6a4 commit bda8038
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 116 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ If this is your first time using Roboto, we recommend reading the [docs](https:/

See below for getting started [examples](#getting-started).

<img src="https://github.com/user-attachments/assets/5f9a87e5-9012-4ec4-9a67-abf5ef733f5b" width="700"/>

## Sign up

In order to use the Roboto SDK and CLI you'll need to create an account and get an access token.
Expand Down
214 changes: 112 additions & 102 deletions build-support/lockfiles/python-default.lock

Large diffs are not rendered by default.

52 changes: 46 additions & 6 deletions src/roboto/domain/events/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
)
from ...http import RobotoClient
from ...logging import default_logger
from ...sentinels import NotSet, NotSetType
from ...sentinels import (
NotSet,
NotSetType,
remove_not_set,
)
from ...time import to_epoch_nanoseconds
from ...updates import (
MetadataChangeset,
Expand Down Expand Up @@ -206,6 +210,14 @@ def __init__(
def __repr__(self) -> str:
return self.__record.model_dump_json()

@property
def created(self) -> datetime.datetime:
return self.__record.created

@property
def created_by(self) -> str:
return self.__record.created_by

@property
def dataset_ids(self) -> list[str]:
return [
Expand All @@ -214,6 +226,10 @@ def dataset_ids(self) -> list[str]:
if association.is_dataset
]

@property
def description(self) -> typing.Optional[str]:
return self.__record.description

@property
def end_time(self) -> int:
"""Epoch nanoseconds"""
Expand All @@ -239,6 +255,18 @@ def message_path_ids(self) -> list[str]:
if association.is_msgpath
]

@property
def metadata(self) -> dict[str, typing.Any]:
return self.__record.metadata

@property
def modified(self) -> datetime.datetime:
return self.__record.modified

@property
def modified_by(self) -> str:
return self.__record.modified_by

@property
def name(self) -> str:
return self.__record.name
Expand All @@ -252,6 +280,10 @@ def start_time(self) -> int:
"""Epoch nanoseconds"""
return self.__record.start_time

@property
def tags(self) -> list[str]:
return self.__record.tags

@property
def topic_ids(self) -> list[str]:
return [
Expand Down Expand Up @@ -481,12 +513,20 @@ def to_dict(self) -> dict[str, typing.Any]:

def update(
self,
description: typing.Optional[typing.Union[str, NotSetType]] = NotSet,
metadata_changeset: typing.Optional[MetadataChangeset] = None,
name: typing.Optional[str] = None,
description: typing.Union[str, None, NotSetType] = NotSet,
metadata_changeset: typing.Union[MetadataChangeset, NotSetType] = NotSet,
name: typing.Union[str, NotSetType] = NotSet,
start_time: typing.Union[int, NotSetType] = NotSet,
end_time: typing.Union[int, NotSetType] = NotSet,
) -> "Event":
request = UpdateEventRequest(
description=description, metadata_changeset=metadata_changeset, name=name
request = remove_not_set(
UpdateEventRequest(
description=description,
metadata_changeset=metadata_changeset,
name=name,
start_time=start_time,
end_time=end_time,
)
)

self.__record = self.__roboto_client.put(
Expand Down
17 changes: 14 additions & 3 deletions src/roboto/domain/events/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,33 @@ class UpdateEventRequest(pydantic.BaseModel):
Request payload for the Update Event operation. Allows any of the mutable fields of an event to be changed.
"""

description: typing.Optional[typing.Union[str, NotSetType]] = NotSet
description: typing.Union[str, None, NotSetType] = NotSet
"""
An optional human-readable description of the event.
"""

metadata_changeset: typing.Optional[MetadataChangeset] = None
metadata_changeset: typing.Union[MetadataChangeset, NotSetType] = NotSet
"""
Metadata and tag changes to make for this event
"""

name: typing.Optional[str] = None
name: typing.Union[str, NotSetType] = NotSet
"""
A brief human-readable name for the event. Many events can have the same name. "Takeoff", "Crash", "CPU Spike",
"Bad Image Quality", and "Unexpected Left" are a few potential examples.
"""

start_time: typing.Union[int, NotSetType] = NotSet
"""
The start time of the event, in nanoseconds since epoch (assumed Unix epoch).
"""

end_time: typing.Union[int, NotSetType] = NotSet
"""
The end time of the event, in nanoseconds since epoch (assumed Unix epoch). This can be equal to start_time if
the event is discrete, but can never be less than start_time.
"""

# This is required to get NotSet/NotSetType to serialize appropriately.
model_config = pydantic.ConfigDict(
extra="forbid", json_schema_extra=NotSetType.openapi_schema_modifier
Expand Down
4 changes: 2 additions & 2 deletions src/roboto/domain/files/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class File:
__roboto_client: RobotoClient

@staticmethod
def construct_s3_obj_arn(bucket: str, key: str) -> str:
return f"arn:aws:s3:::{bucket}/{key}"
def construct_s3_obj_arn(bucket: str, key: str, partition: str = "aws") -> str:
return f"arn:{partition}:s3:::{bucket}/{key}"

@staticmethod
def construct_s3_obj_uri(
Expand Down
3 changes: 3 additions & 0 deletions src/roboto/http/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ def to_record_list(
for item in self.to_dict(json_path=["data"])
]

def to_string_list(self) -> list[str]:
return [str(item) for item in self.to_dict(json_path=["data"])]

def to_dict(self, json_path: typing.Optional[list[str]] = None) -> typing.Any:
with self.__response:
unmarsalled = json.loads(self.__response.read().decode("utf-8"))
Expand Down
1 change: 1 addition & 0 deletions src/roboto/query/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class QueryTarget(str, enum.Enum):
Files = "files"
Topics = "topics"
TopicMessagePaths = "topic_message_paths"
Events = "events"


class QueryStatus(enum.Enum):
Expand Down
1 change: 1 addition & 0 deletions src/roboto/regionalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class RobotoRegion(str, enum.Enum):
"""

US_WEST = "us-west"
US_GOV_WEST = "us-gov-west"
US_EAST = "us-east"
EU_CENTRAL = "eu-central"
18 changes: 17 additions & 1 deletion src/roboto/roboto_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
from .domain import (
collections as roboto_collections,
)
from .domain import datasets, files, topics
from .domain import (
datasets,
events,
files,
topics,
)
from .query import Query, QueryClient, QueryTarget


Expand Down Expand Up @@ -111,3 +116,14 @@ def find_topics(
topics.TopicRecord.model_validate(result),
self.__query_client.roboto_client,
)

def find_events(
self, query: typing.Optional[Query] = None, timeout_seconds: float = math.inf
) -> collections.abc.Generator[events.Event]:
for result in self.__query_client.submit_query(
query, QueryTarget.Events, timeout_seconds
):
yield events.Event(
events.EventRecord.model_validate(result),
self.__query_client.roboto_client,
)
2 changes: 1 addition & 1 deletion src/roboto/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def combine(self, other: "MetadataChangeset") -> "MetadataChangeset":
)

def is_empty(self) -> bool:
return not any(
return not self.replace_all and not any(
[
self.put_tags,
self.remove_tags,
Expand Down
2 changes: 1 addition & 1 deletion src/roboto/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.12.0"
__version__ = "0.13.0"

__all__= ("__version__",)

0 comments on commit bda8038

Please sign in to comment.