Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion examples/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MyStrEnum(str, enum.Enum):
if __name__ == "__main__":
my_panel = nipanel.StreamlitPanel(
panel_id="placeholder",
streamlit_script_uri=__file__,
streamlit_script_path=__file__,
)

my_types = {
Expand Down
7 changes: 2 additions & 5 deletions examples/sample/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@

panel = nipanel.StreamlitPanel(
panel_id="sample_panel",
streamlit_script_uri=panel_script_path,
streamlit_script_path=panel_script_path,
)
panel.open_panel()
panel.set_value("sample_string", "Hello, World!")
panel.set_value("sample_int", 42)
panel.set_value("sample_float", 3.14)
panel.set_value("sample_bool", True)
panel.set_value("float_values", [1.1, 2.2, 3.3])

input("Press Enter to close the panel...")

panel.close_panel(reset=True)
print(f"Panel URL: {panel.panel_url}")
68 changes: 35 additions & 33 deletions protos/ni/pythonpanel/v1/python_panel_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ option ruby_package = "NI::PythonPanel::V1";

// Service interface for interacting with python panels
service PythonPanelService {
// Enumerate the panels available in the system, including information about the state of the panels and what values they have.
// Start a panel (or connect to if it has already been started)
// Status Codes for errors:
rpc EnumeratePanels(EnumeratePanelsRequest) returns (EnumeratePanelsResponse);
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
// - NOT_FOUND: the file for the panel was not found
rpc StartPanel(StartPanelRequest) returns (StartPanelResponse);

// Open a panel
// Stop a panel
// Status Codes for errors:
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
// - NOT_FOUND: the file for the panel was not found
rpc OpenPanel(OpenPanelRequest) returns (OpenPanelResponse);
rpc StopPanel(StopPanelRequest) returns (StopPanelResponse);

// Enumerate the panels available in the system, including information about the state of the panels and what values they have.
// Status Codes for errors:
rpc EnumeratePanels(EnumeratePanelsRequest) returns (EnumeratePanelsResponse);

// Get a value for a control on the panel
// Status Codes for errors:
Expand All @@ -36,41 +41,49 @@ service PythonPanelService {
// Status Codes for errors:
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
rpc SetValue(SetValueRequest) returns (SetValueResponse);
}

// Close a panel
// Status Codes for errors:
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
rpc ClosePanel(ClosePanelRequest) returns (ClosePanelResponse);
message StartPanelRequest {
// Unique ID of the panel
string panel_id = 1;

// Absolute path of the panel script's file on disk, or network path to the file
string panel_script_path = 2;
}

message EnumeratePanelsRequest {
message StartPanelResponse {
// Location of the panel's webpage
string panel_url = 1;
}

message PanelInformation {
message StopPanelRequest {
// Unique ID of the panel
string panel_id = 1;

// Is the panel currently open?
bool is_open = 2;
// Reset all storage associated with panel
bool reset = 2;
}

// IDs of all of the values associated with the panel
repeated string value_ids = 3;
message StopPanelResponse {
}

message EnumeratePanelsResponse {
// The list of panels available in the system
repeated PanelInformation panels = 1;
message EnumeratePanelsRequest {
}

message OpenPanelRequest {
message PanelInformation {
// Unique ID of the panel
string panel_id = 1;

// Absolute path of the panel's file on disk, or network path to the file
string panel_uri = 2;
// Location of the panel's webpage
string panel_url = 2;

// IDs of all of the values associated with the panel
repeated string value_ids = 3;
}

message OpenPanelResponse {
message EnumeratePanelsResponse {
// The list of panels available in the system
repeated PanelInformation panels = 1;
}

message GetValueRequest {
Expand Down Expand Up @@ -98,15 +111,4 @@ message SetValueRequest {
}

message SetValueResponse {
}

message ClosePanelRequest {
// Unique ID of the panel
string panel_id = 1;

// Reset all storage associated with panel
bool reset = 2;
}

message ClosePanelResponse {
}
50 changes: 25 additions & 25 deletions src/ni/pythonpanel/v1/python_panel_service_pb2.py

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

132 changes: 69 additions & 63 deletions src/ni/pythonpanel/v1/python_panel_service_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,88 +14,124 @@ import typing
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing.final
class EnumeratePanelsRequest(google.protobuf.message.Message):
class StartPanelRequest(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANEL_ID_FIELD_NUMBER: builtins.int
PANEL_SCRIPT_PATH_FIELD_NUMBER: builtins.int
panel_id: builtins.str
"""Unique ID of the panel"""
panel_script_path: builtins.str
"""Absolute path of the panel script's file on disk, or network path to the file"""
def __init__(
self,
*,
panel_id: builtins.str = ...,
panel_script_path: builtins.str = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_script_path", b"panel_script_path"]) -> None: ...

global___EnumeratePanelsRequest = EnumeratePanelsRequest
global___StartPanelRequest = StartPanelRequest

@typing.final
class PanelInformation(google.protobuf.message.Message):
class StartPanelResponse(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANEL_URL_FIELD_NUMBER: builtins.int
panel_url: builtins.str
"""Location of the panel's webpage"""
def __init__(
self,
*,
panel_url: builtins.str = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["panel_url", b"panel_url"]) -> None: ...

global___StartPanelResponse = StartPanelResponse

@typing.final
class StopPanelRequest(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANEL_ID_FIELD_NUMBER: builtins.int
IS_OPEN_FIELD_NUMBER: builtins.int
VALUE_IDS_FIELD_NUMBER: builtins.int
RESET_FIELD_NUMBER: builtins.int
panel_id: builtins.str
"""Unique ID of the panel"""
is_open: builtins.bool
"""Is the panel currently open?"""
@property
def value_ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
"""IDs of all of the values associated with the panel"""

reset: builtins.bool
"""Reset all storage associated with panel"""
def __init__(
self,
*,
panel_id: builtins.str = ...,
is_open: builtins.bool = ...,
value_ids: collections.abc.Iterable[builtins.str] | None = ...,
reset: builtins.bool = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["is_open", b"is_open", "panel_id", b"panel_id", "value_ids", b"value_ids"]) -> None: ...
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "reset", b"reset"]) -> None: ...

global___PanelInformation = PanelInformation
global___StopPanelRequest = StopPanelRequest

@typing.final
class EnumeratePanelsResponse(google.protobuf.message.Message):
class StopPanelResponse(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANELS_FIELD_NUMBER: builtins.int
@property
def panels(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___PanelInformation]:
"""The list of panels available in the system"""
def __init__(
self,
) -> None: ...

global___StopPanelResponse = StopPanelResponse

@typing.final
class EnumeratePanelsRequest(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

def __init__(
self,
*,
panels: collections.abc.Iterable[global___PanelInformation] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["panels", b"panels"]) -> None: ...

global___EnumeratePanelsResponse = EnumeratePanelsResponse
global___EnumeratePanelsRequest = EnumeratePanelsRequest

@typing.final
class OpenPanelRequest(google.protobuf.message.Message):
class PanelInformation(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANEL_ID_FIELD_NUMBER: builtins.int
PANEL_URI_FIELD_NUMBER: builtins.int
PANEL_URL_FIELD_NUMBER: builtins.int
VALUE_IDS_FIELD_NUMBER: builtins.int
panel_id: builtins.str
"""Unique ID of the panel"""
panel_uri: builtins.str
"""Absolute path of the panel's file on disk, or network path to the file"""
panel_url: builtins.str
"""Location of the panel's webpage"""
@property
def value_ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
"""IDs of all of the values associated with the panel"""

def __init__(
self,
*,
panel_id: builtins.str = ...,
panel_uri: builtins.str = ...,
panel_url: builtins.str = ...,
value_ids: collections.abc.Iterable[builtins.str] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_uri", b"panel_uri"]) -> None: ...
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_url", b"panel_url", "value_ids", b"value_ids"]) -> None: ...

global___OpenPanelRequest = OpenPanelRequest
global___PanelInformation = PanelInformation

@typing.final
class OpenPanelResponse(google.protobuf.message.Message):
class EnumeratePanelsResponse(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANELS_FIELD_NUMBER: builtins.int
@property
def panels(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___PanelInformation]:
"""The list of panels available in the system"""

def __init__(
self,
*,
panels: collections.abc.Iterable[global___PanelInformation] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["panels", b"panels"]) -> None: ...

global___OpenPanelResponse = OpenPanelResponse
global___EnumeratePanelsResponse = EnumeratePanelsResponse

@typing.final
class GetValueRequest(google.protobuf.message.Message):
Expand Down Expand Up @@ -172,33 +208,3 @@ class SetValueResponse(google.protobuf.message.Message):
) -> None: ...

global___SetValueResponse = SetValueResponse

@typing.final
class ClosePanelRequest(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

PANEL_ID_FIELD_NUMBER: builtins.int
RESET_FIELD_NUMBER: builtins.int
panel_id: builtins.str
"""Unique ID of the panel"""
reset: builtins.bool
"""Reset all storage associated with panel"""
def __init__(
self,
*,
panel_id: builtins.str = ...,
reset: builtins.bool = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "reset", b"reset"]) -> None: ...

global___ClosePanelRequest = ClosePanelRequest

@typing.final
class ClosePanelResponse(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

def __init__(
self,
) -> None: ...

global___ClosePanelResponse = ClosePanelResponse
Loading