Skip to content

Commit

Permalink
Add a jupyter document for creating and managing service groups
Browse files Browse the repository at this point in the history
This commit depends on the PDO update for persistent service
groups database.

Add a jupyter notebook for creating, managing and using service
groups. This update includes widgets to simplify selection and
use of service groups.

Also adds a jupyter notebook for demonstrating different widgets
that are not part of the management pages.

Signed-off-by: Mic Bowman <mic.bowman@intel.com>
  • Loading branch information
cmickeyb committed Mar 29, 2024
1 parent a76c05f commit 0d22c32
Show file tree
Hide file tree
Showing 5 changed files with 483 additions and 2 deletions.
62 changes: 62 additions & 0 deletions docs/notebooks/documents/service_groups_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.1
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Service Groups Management for PDO Contracts
#
# This notebook helps to manage the services database.

# %%
import pdo.contracts.jupyter as pc_jupyter
import IPython.display as ip_display
import ipywidgets

from pdo.contracts.services import service_labels
from pdo.contracts.groups import ServiceGroupListWidget
from pdo.contracts.groups import EnclaveServiceGroupCreateWidget
from pdo.contracts.groups import ProvisioningServiceGroupCreateWidget
from pdo.contracts.groups import StorageServiceGroupCreateWidget

pc_jupyter.load_ipython_extension(get_ipython())

try :
state
except NameError:
(state, bindings) = pc_jupyter.initialize_environment('unknown')

# %% [markdown]
# ## List of Available Service Groups
#
# %%
children = map(lambda stype : ServiceGroupListWidget(state, bindings, stype), service_labels.keys())
service_list_widget = ipywidgets.Tab(children=list(children), titles=list(service_labels.values()))
ip_display.display(service_list_widget)

# %% [markdown]
# ## Create a New Enclave Service Group
#
# %%
ip_display.display(EnclaveServiceGroupCreateWidget(state, bindings))

# %% [markdown]
# ## Create a New Provisioning Service Group
#
# %%
ip_display.display(ProvisioningServiceGroupCreateWidget(state, bindings))

# %% [markdown]
# ## Create a New Storage Service Group
#
# %%
ip_display.display(StorageServiceGroupCreateWidget(state, bindings))
81 changes: 81 additions & 0 deletions docs/notebooks/documents/widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.1
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Sample Widgets
# ## WORK IN PROGRESS
#
# This notebook demonstrates a variety of Jupyter widgets for PDO.

# %%
import pdo.contracts.jupyter as pc_jupyter
import IPython.display as ip_display
import ipywidgets

from pdo.contracts.services import service_labels, ServiceSelectionWidget
from pdo.contracts.groups import ServiceGroupSelectionWidget

pc_jupyter.load_ipython_extension(get_ipython())

try :
state
except NameError:
(state, bindings) = pc_jupyter.initialize_environment('unknown')

# %% [markdown]
# # Key Management Widgets
# %% [markdown]
# ## Key Selection Widgets
# %%
def display_key(selection, output) :
with output :
print("Selection: {}".format(selection))

public_key_widget = pc_jupyter.keys.PublicKeySelectionWidget(state, bindings, "Display", display_key)
ip_display.display(public_key_widget)

private_key_widget = pc_jupyter.keys.PrivateKeySelectionWidget(state, bindings, "Display", display_key)
ip_display.display(private_key_widget)

# %% [markdown]
# # Service Management Widgets
# %% [markdown]
# ## Service Selection Widget
# %%
def display_service(service_type, selection, output) :
with output :
print("Selection [{}]: {}".format(service_type, ", ".join(selection)))

def create_service_selection(service_type) :
return ServiceSelectionWidget(state, bindings, service_type, 'Display', display_service)

children = map(lambda service_type : create_service_selection(service_type), service_labels.keys())
service_selection_widget = ipywidgets.Tab(children=list(children), titles=list(service_labels.values()))
ip_display.display(service_selection_widget)

# %% [markdown]
# # Service Groups Widgets
# %% [markdown]
# ## Select Service Groups
# %%
def display_group(service_type, selection, output) :
with output :
print("Selection [{}]: {}".format(service_type, selection))

def create_group_selection(service_type) :
return ServiceGroupSelectionWidget(state, bindings, service_type, 'Display', display_group)

children = map(lambda service_type : create_group_selection(service_type), service_labels.keys())
group_selection_widget = ipywidgets.Tab(children=list(children), titles=list(service_labels.values()))
ip_display.display(group_selection_widget)
2 changes: 1 addition & 1 deletion exchange-contract/pdo/contracts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__all__ = [ 'common', 'jupyter', 'keys', 'services' ]
__all__ = [ 'common', 'jupyter', 'keys', 'service_groups', 'services' ]
Loading

0 comments on commit 0d22c32

Please sign in to comment.