Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ See [GitHub's official documentation](https://help.github.com/articles/using-pul

# Getting Started

This is the command to generate the files in /src/ni/pythonpanel/v1/:
`poetry run python -m grpc_tools.protoc --proto_path=protos --python_out=src/ --grpc_python_out=src/ --mypy_out=src/ --mypy_grpc_out=src/ ni/pythonpanel/v1/python_panel_service.proto`
This is the command to generate the files in /src/ni/panels/v1/:
`poetry run python -m grpc_tools.protoc --proto_path=protos --python_out=src/ --grpc_python_out=src/ --mypy_out=src/ --mypy_grpc_out=src/ ni/panels/v1/panel_service.proto ni/panels/v1/panel_types.proto ni/panels/v1/streamlit_panel_configuration.proto`

# Testing

Expand Down
2 changes: 1 addition & 1 deletion examples/all_types/all_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import nipanel

panel_script_path = Path(__file__).with_name("all_types_panel.py")
panel = nipanel.create_panel(panel_script_path)
panel = nipanel.create_streamlit_panel(panel_script_path)

print("Setting values")
for name, value in all_types_with_values.items():
Expand Down
2 changes: 1 addition & 1 deletion examples/all_types/all_types_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
st.set_page_config(page_title="All Types Example", page_icon="📊", layout="wide")
st.title("All Types Example")

panel = nipanel.get_panel_accessor()
panel = nipanel.get_streamlit_panel_accessor()
for name in all_types_with_values.keys():
st.markdown("---")

Expand Down
2 changes: 1 addition & 1 deletion examples/hello/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import nipanel

panel_script_path = Path(__file__).with_name("hello_panel.py")
panel = nipanel.create_panel(panel_script_path)
panel = nipanel.create_streamlit_panel(panel_script_path)

panel.set_value("hello_string", "Hello, World!")

Expand Down
2 changes: 1 addition & 1 deletion examples/hello/hello_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
st.set_page_config(page_title="Hello World Example", page_icon="📊", layout="wide")
st.title("Hello World Example")

panel = nipanel.get_panel_accessor()
panel = nipanel.get_streamlit_panel_accessor()
st.write(panel.get_value("hello_string", ""))
2 changes: 1 addition & 1 deletion examples/nidaqmx/nidaqmx_continuous_analog_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import nipanel

panel_script_path = Path(__file__).with_name("nidaqmx_continuous_analog_input_panel.py")
panel = nipanel.create_panel(panel_script_path)
panel = nipanel.create_streamlit_panel(panel_script_path)

try:
print(f"Panel URL: {panel.panel_url}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
unsafe_allow_html=True,
)

panel = nipanel.get_panel_accessor()
panel = nipanel.get_streamlit_panel_accessor()
is_running = panel.get_value("is_running", False)

if is_running:
Expand Down
2 changes: 1 addition & 1 deletion examples/niscope/niscope_ex_fetch_forever.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import nipanel

panel_script_path = Path(__file__).with_name("niscope_ex_fetch_forever_panel.py")
panel = nipanel.create_panel(panel_script_path)
panel = nipanel.create_streamlit_panel(panel_script_path)

print(f"Panel URL: {panel.panel_url}")

Expand Down
2 changes: 1 addition & 1 deletion examples/niscope/niscope_ex_fetch_forever_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
st.set_page_config(page_title="NI-SCOPE Example", page_icon="📈", layout="wide")
st.title("NIScope EX Fetch Forever")

panel = nipanel.get_panel_accessor()
panel = nipanel.get_streamlit_panel_accessor()

waveform = panel.get_value("Waveform", [0])

Expand Down
2 changes: 1 addition & 1 deletion examples/performance_checker/performance_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


panel_script_path = Path(__file__).with_name("performance_checker_panel.py")
panel = nipanel.create_panel(panel_script_path)
panel = nipanel.create_streamlit_panel(panel_script_path)

amplitude = 1.0
frequency = 1.0
Expand Down
4 changes: 2 additions & 2 deletions examples/performance_checker/performance_checker_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def profile_get_value(
panel: "nipanel.StreamlitPanelValueAccessor",
panel: "nipanel.PanelValueAccessor",
value_id: str,
default_value: Any = None,
num_runs: int = 5,
Expand Down Expand Up @@ -69,7 +69,7 @@ def profile_get_value(
max_refresh_time = max(refresh_history) if refresh_history else 0
avg_refresh_time = statistics.mean(refresh_history) if refresh_history else 0

panel = nipanel.get_panel_accessor()
panel = nipanel.get_streamlit_panel_accessor()

num_timing_runs = 5
time_points, time_points_ms = profile_get_value(panel, "time_points", [0.0], num_timing_runs)
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_graph/simple_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


panel_script_path = Path(__file__).with_name("simple_graph_panel.py")
panel = nipanel.create_panel(panel_script_path)
panel = nipanel.create_streamlit_panel(panel_script_path)

amplitude = 1.0
frequency = 1.0
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_graph/simple_graph_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
st.set_page_config(page_title="Simple Graph Example", page_icon="📈", layout="wide")
st.title("Simple Graph Example")

panel = nipanel.get_panel_accessor()
panel = nipanel.get_streamlit_panel_accessor()
time_points = panel.get_value("time_points", [0.0])
sine_values = panel.get_value("sine_values", [0.0])
amplitude = panel.get_value("amplitude", 1.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
syntax = "proto3";

package ni.pythonpanel.v1;
package ni.panels.v1;

import "google/protobuf/any.proto";

option cc_enable_arenas = true;
option csharp_namespace = "NationalInstruments.PythonPanel.V1";
option go_package = "pythonpanelv1";
option csharp_namespace = "NationalInstruments.Panels.V1";
option go_package = "panelsv1";
option java_multiple_files = true;
option java_outer_classname = "PythonPanelServiceProto";
option java_package = "com.ni.pythonpanel.v1";
option objc_class_prefix = "NIPP";
option php_namespace = "NI\\PythonPanel\\V1";
option ruby_package = "NI::PythonPanel::V1";

// Service interface for interacting with python panels
service PythonPanelService {
// Start a panel (or connect to if it has already been started)
option java_outer_classname = "PanelsProto";
option java_package = "com.ni.panels.v1";
option objc_class_prefix = "NIPS";
option php_namespace = "NI\\Panels\\V1";
option ruby_package = "NI::Panels::V1";

// Service interface for interacting with NI panels
service PanelService {
// Start a panel using the provided configuration (or connect to if it has already been started)
// Status Codes for errors:
// - INVALID_ARGUMENT:
// - The panel script filename doesn't end in .py.
// - The panel identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
// - The panel configuration has an invalid argument.
// - NOT_FOUND:
// - The panel script file was not found.
// - The python executable file was not found.
// - The panel configuration includes a file that was not found.
rpc StartPanel(StartPanelRequest) returns (StartPanelResponse);

// Stop a panel
Expand Down Expand Up @@ -64,16 +63,13 @@ 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;

// Path to the python interpreter to use for the panel script.
string python_path = 3;
// Configuration for the panel, packed as Any
google.protobuf.Any panel_configuration = 2;
}

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

message StopPanelRequest {
Expand All @@ -94,8 +90,8 @@ message PanelInformation {
// Unique ID of the panel
string panel_id = 1;

// Location of the panel's webpage
string panel_url = 2;
// Location of the panel
string panel_uri = 2;

// IDs of all of the values associated with the panel
repeated string value_ids = 3;
Expand Down Expand Up @@ -128,7 +124,7 @@ message TryGetValueRequest {
}

message TryGetValueResponse {
// The value, if it was found
// The value, if it was found
optional google.protobuf.Any value = 1;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
syntax = "proto3";

package ni.pythonpanel.v1;
package ni.panels.v1;

option cc_enable_arenas = true;
option csharp_namespace = "NationalInstruments.PythonPanel.V1";
option go_package = "pythonpanelv1";
option csharp_namespace = "NationalInstruments.Panels.V1";
option go_package = "panelsv1";
option java_multiple_files = true;
option java_outer_classname = "PythonPanelServiceProto";
option java_package = "com.ni.pythonpanel.v1";
option objc_class_prefix = "NIPP";
option php_namespace = "NI\\PythonPanel\\V1";
option ruby_package = "NI::PythonPanel::V1";
option java_outer_classname = "PanelsProto";
option java_package = "com.ni.panels.v1";
option objc_class_prefix = "NIPS";
option php_namespace = "NI\\Panels\\V1";
option ruby_package = "NI::Panels::V1";

message BoolCollection {
repeated bool values = 1;
Expand Down
23 changes: 23 additions & 0 deletions protos/ni/panels/v1/streamlit_panel_configuration.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";

package ni.panels.v1;

option cc_enable_arenas = true;
option csharp_namespace = "NationalInstruments.Panels.V1";
option go_package = "panelsv1";
option java_multiple_files = true;
option java_outer_classname = "StreamlitPanelConfigurationProto";
option java_package = "com.ni.panels.v1";
option objc_class_prefix = "NIPS";
option php_namespace = "NI\\Panels\\V1";
option ruby_package = "NI::Panels::V1";

// Pack this into PanelService.StartPanelRequest.panel_configuration to start a Streamlit panel.
message StreamlitPanelConfiguration
{
// Absolute path of the streamlit script file on disk, or network path to the file. This must end in ".py".
string panel_script_path = 1;

// Path to the python interpreter to use for running the streamlit script.
string python_path = 2;
}
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ requires = ["poetry-core>=1.8.0"]
build-backend = "poetry.core.masonry.api"

[tool.ni-python-styleguide]
extend_exclude = ".tox,docs,src/ni/pythonpanel/v1,src/ni/protobuf/types/"
extend_exclude = ".tox,docs,src/ni/panels/v1,src/ni/protobuf/types/"

[tool.black]
extend-exclude = '\.tox/|docs/|src/ni/pythonpanel/v1/|src/ni/protobuf/types/'
extend-exclude = '\.tox/|docs/|src/ni/panels/v1/|src/ni/protobuf/types/'
line-length = 100

[tool.mypy]
Expand Down Expand Up @@ -105,4 +105,4 @@ testpaths = ["src/nipanel", "tests"]

[tool.pyright]
include = ["examples/", "src/", "tests/"]
exclude = ["src/ni/protobuf/types/", "src/ni/pythonpanel/v1/","examples/nidaqmx/nidaqmx_continuous_analog_input.py","examples/niscope/niscope_ex_fetch_forever.py"]
exclude = ["src/ni/protobuf/types/", "src/ni/panels/v1/","examples/nidaqmx/nidaqmx_continuous_analog_input.py","examples/niscope/niscope_ex_fetch_forever.py"]
1 change: 1 addition & 0 deletions src/ni/panels/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""gRPC stubs for NI Panels."""
1 change: 1 addition & 0 deletions src/ni/panels/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""gRPC client for NI Panels."""
53 changes: 53 additions & 0 deletions src/ni/panels/v1/panel_service_pb2.py

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

Loading