Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose create_library_signal and create_tag #33

Merged
merged 6 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_signal(self, request: GetSignalRequest) -> Signal:
return self._request("GET", request.name, Signal())

def create_signal(self, request: CreateSignalRequest) -> Signal:
return self._request("POST", "signals", Signal(), request.signal)
return self._request("POST", f"signals?createLibrarySignal={request.create_library_signal}", Signal(), request.signal)

def delete_signal(self, request: DeleteSignalRequest) -> None:
self._request("DELETE", request.name, None)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_time_series(self, request: GetTimeSeriesRequest) -> TimeSeries:

def create_time_series(self, request: CreateTimeSeriesRequest) -> TimeSeries:
return self._request(
"POST", request.time_series.name, TimeSeries(), body=request.time_series
"POST", f"{request.time_series.name}?createTag={request.create_tag}", TimeSeries(), body=request.time_series
)

def update_time_series(self, request: UpdateTimeSeriesRequest) -> TimeSeries:
Expand Down
5 changes: 3 additions & 2 deletions exabel_data_sdk/client/api/signal_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ def get_signal(self, name: str) -> Optional[Signal]:
raise
return Signal.from_proto(response)

def create_signal(self, signal: Signal) -> Signal:
def create_signal(self, signal: Signal, create_library_signal: bool=False) -> Signal:
"""
Create one signal and returns it.

Args:
signal: The signal to create.
create_library_signal: Set to true to add the signal to the library when created.
"""
response = self.client.create_signal(
CreateSignalRequest(signal=signal.to_proto()),
CreateSignalRequest(signal=signal.to_proto(), create_library_signal=create_library_signal),
)
return Signal.from_proto(response)

Expand Down
8 changes: 6 additions & 2 deletions exabel_data_sdk/client/api/time_series_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def get_time_series(

return self._time_series_points_to_series(time_series.points, time_series.name)

def create_time_series(self, name: str, series: pd.Series) -> None:
def create_time_series(self, name: str, series: pd.Series, create_tag: bool=False) -> None:
"""
Create a time series.

Expand All @@ -127,11 +127,15 @@ def create_time_series(self, name: str, series: pd.Series) -> None:
customer has access to. If ns2 is not empty, it must be equals to ns3,
and if ns1 is not empty, all three namespaces must be equal.
series: The time series data
create_tag: Set to true to create a tag for every entity type a signal has time series
for. If a tag already exists, it will be updated when time series are created
(or deleted) regardless of the value of this flag.
"""
time_series_points = self._series_to_time_series_points(series)
self.client.create_time_series(
CreateTimeSeriesRequest(
time_series=ProtoTimeSeries(name=name, points=time_series_points)
time_series=ProtoTimeSeries(name=name, points=time_series_points),
create_tag=create_tag
),
)

Expand Down
10 changes: 9 additions & 1 deletion exabel_data_sdk/scripts/create_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,22 @@ def __init__(self, argv: Sequence[str], description: str):
default="",
help="One or more paragraphs of text description",
)
self.parser.add_argument(
"--create-library-signal",
required=False,
type=bool,
default=False,
help="Set to true to create a library signal",
)

def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
signal = client.signal_api.create_signal(
Signal(
name=args.name,
display_name=args.display_name,
description=args.description,
)
),
create_library_signal=args.create_library_signal
)
print("Successfully created signal:")
print(signal)
Expand Down
20 changes: 10 additions & 10 deletions exabel_data_sdk/stubs/exabel/api/data/v1/signal_service_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,22 @@ type___GetSignalRequest = GetSignalRequest

class CreateSignalRequest(google___protobuf___message___Message):
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
no_library_signal: builtin___bool = ...
create_library_signal: builtin___bool = ...
@property
def signal(self) -> exabel___api___data___v1___signal_messages_pb2___Signal: ...
def __init__(
self,
*,
signal: typing___Optional[exabel___api___data___v1___signal_messages_pb2___Signal] = None,
no_library_signal: typing___Optional[builtin___bool] = None,
create_library_signal: typing___Optional[builtin___bool] = None,
) -> None: ...
def HasField(
self, field_name: typing_extensions___Literal["signal", b"signal"]
) -> builtin___bool: ...
def ClearField(
self,
field_name: typing_extensions___Literal[
"no_library_signal", b"no_library_signal", "signal", b"signal"
"create_library_signal", b"create_library_signal", "signal", b"signal"
],
) -> None: ...

Expand Down
26 changes: 13 additions & 13 deletions exabel_data_sdk/stubs/exabel/api/data/v1/time_series_service_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading