Skip to content

Commit

Permalink
add projects and teams back in and put iterators back in place, plus …
Browse files Browse the repository at this point in the history
…docs
  • Loading branch information
mike-jt79 committed Nov 27, 2020
1 parent 446ae45 commit b59090e
Show file tree
Hide file tree
Showing 9 changed files with 326 additions and 174 deletions.
213 changes: 125 additions & 88 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To list the available applications you can use the list_applications() method. T
# List all applications
apps = client.catalog.list_applications()
print("ID | Application | Version | Cluster IDs")
for app in apps
for app in apps:
for version in app.versions:
print("{} | {} | {} | {}".format(version.id, app.product.name, version.version, version.queue_ids))
Expand Down Expand Up @@ -96,8 +96,8 @@ To list queues use the list_clusters() method. You can filter by cluster name or
# List all clusters
clusters = client.catalog.list_clusters()
for cluster in clusters.results:
print("{} | {} | {}".format(cluster.id, cluster.display_name, cluster.display_description))
for cluster in clusters:
print("{} | {} | {}".format(cluster.id, cluster.name, cluster.description))
# List clusters with a filter for a cluster name
clusters = client.catalog.list_clusters(cluster_name="csd3")
Expand Down Expand Up @@ -206,7 +206,7 @@ To list the types of desktop nodes available in epic use the catalog.list_deskto
# Look at the results
print("Name | Version Name | Version ID | Valid Node Types | Valid connection Types")
for desktop in desktops.results:
for desktop in desktops:
valid_connections = [conn.id for conn in desktop.connection_types]
valid_node_types = [node_type.id for node_type in desktop.node_types]
for version in desktop.versions:
Expand All @@ -223,85 +223,83 @@ An example json output from list_desktops is shown below

.. code-block:: json
{'count': 2,
'next': None,
'previous': None,
'results': [{'connection_types': [{'description': 'Connect using Nice DCV in '
'your browser',
'id': 3,
'name': 'DCV'}],
'description': 'NICE Desktop Cloud Visualization (DCV) enables '
'remote access 2D/3D interactive applications '
'over a standard network. EPIC will start a DCV '
'instance that you can connect to with your '
'browser with several versions of Paraview '
'installed and ready to go.',
'id': 2,
'image': '/media/viz/dcv.png',
'name': 'DCV (Paraview)',
'node_types': [{'cores': 4,
'description': '4 Broadwell CPU Cores, 30.5GiB '
'Memory, 1 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 1,
'id': 1,
'name': 'Standard GPU Node'},
{'cores': 32,
'description': '32 Broadwell CPU Cores, 244GiB '
'Memory, 2 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 2,
'id': 2,
'name': 'Large GPU Node'},
{'cores': 64,
'description': '64 Broadwell CPU Cores, 488GiB '
'Memory, 4 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 4,
'id': 3,
'name': 'Extra Large GPU Node'}],
'versions': [{'application_version': 'DCV 2017', 'id': 4}]},
{'connection_types': [{'description': 'Connect using Nice DCV in '
'your browser',
'id': 3,
'name': 'DCV'}],
'description': 'zCAD is an CAD repair and mesh generation tool '
'from Zenotech. EPIC will start a DCV instance '
'that you can connect to with your browser with '
'zCAD and other Zenotech tools installed and '
'ready to go.',
'id': 3,
'image': '/media/viz/zcad.png',
'name': 'zCAD',
'node_types': [{'cores': 4,
'description': '4 Broadwell CPU Cores, 30.5GiB '
'Memory, 1 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 1,
'id': 1,
'name': 'Standard GPU Node'},
{'cores': 32,
'description': '32 Broadwell CPU Cores, 244GiB '
'Memory, 2 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 2,
'id': 2,
'name': 'Large GPU Node'},
{'cores': 64,
'description': '64 Broadwell CPU Cores, 488GiB '
'Memory, 4 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 4,
[
{'connection_types': [{'description': 'Connect using Nice DCV in '
'your browser',
'id': 3,
'name': 'Extra Large GPU Node'}],
'versions': [{'application_version': '2016.9', 'id': 5}]}]}
'name': 'DCV'}],
'description': 'NICE Desktop Cloud Visualization (DCV) enables '
'remote access 2D/3D interactive applications '
'over a standard network. EPIC will start a DCV '
'instance that you can connect to with your '
'browser with several versions of Paraview '
'installed and ready to go.',
'id': 2,
'image': '/media/viz/dcv.png',
'name': 'DCV (Paraview)',
'node_types': [{'cores': 4,
'description': '4 Broadwell CPU Cores, 30.5GiB '
'Memory, 1 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 1,
'id': 1,
'name': 'Standard GPU Node'},
{'cores': 32,
'description': '32 Broadwell CPU Cores, 244GiB '
'Memory, 2 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 2,
'id': 2,
'name': 'Large GPU Node'},
{'cores': 64,
'description': '64 Broadwell CPU Cores, 488GiB '
'Memory, 4 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 4,
'id': 3,
'name': 'Extra Large GPU Node'}],
'versions': [{'application_version': 'DCV 2017', 'id': 4}]},
{'connection_types': [{'description': 'Connect using Nice DCV in '
'your browser',
'id': 3,
'name': 'DCV'}],
'description': 'zCAD is an CAD repair and mesh generation tool '
'from Zenotech. EPIC will start a DCV instance '
'that you can connect to with your browser with '
'zCAD and other Zenotech tools installed and '
'ready to go.',
'id': 3,
'image': '/media/viz/zcad.png',
'name': 'zCAD',
'node_types': [{'cores': 4,
'description': '4 Broadwell CPU Cores, 30.5GiB '
'Memory, 1 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 1,
'id': 1,
'name': 'Standard GPU Node'},
{'cores': 32,
'description': '32 Broadwell CPU Cores, 244GiB '
'Memory, 2 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 2,
'id': 2,
'name': 'Large GPU Node'},
{'cores': 64,
'description': '64 Broadwell CPU Cores, 488GiB '
'Memory, 4 x Tesla M60 GPU with '
'2048 CUDA cores and 8GB GPU '
'Memory',
'gpus': 4,
'id': 3,
'name': 'Extra Large GPU Node'}],
'versions': [{'application_version': '2016.9', 'id': 5}]}
]
Jobs
====
Expand Down Expand Up @@ -573,7 +571,7 @@ Desktops

Listing Desktop Instances
-------------------------
To list your desktop instances use the list and get_details methods in :class:`pyepic.client.EPICClient.desktop`.
To list your desktop instances use the list and get_details methods in :class:`pyepic.client.EPICClient.desktops`.

.. code-block:: python
Expand All @@ -582,10 +580,10 @@ To list your desktop instances use the list and get_details methods in :class:`p
client = EPICClient("your_api_token_goes_here")
# List all of my desktop instances
desktops = client.desktop.list()
desktops = client.desktops.list()
# Get the details of desktop id 3
desktop_instance = client.desktop.get_details(3)
desktop_instance = client.desktops.get_details(3)
Getting a quote for a Desktop
Expand All @@ -608,7 +606,7 @@ The valid application_version, node_type and connection_type values can be retri
my_desktop.runtime = 2
# Get a quote for this desktop
quote = client.desktop.get_quote(my_desktop.get_quote_spec()))
quote = client.desktops.get_quote(my_desktop.get_quote_spec()))
An example response for the quote is shown below.

Expand Down Expand Up @@ -637,7 +635,7 @@ The valid application_version, node_type and connection_type values can be retri
my_desktop.runtime = 2
# Launch this desktop
instance = client.desktop.launch(my_desktop.get_launch_spec()))
instance = client.desktops.launch(my_desktop.get_launch_spec()))
# Get the newly created desktop instance id.
id = instance.id
Expand Down Expand Up @@ -682,4 +680,43 @@ Terminate a desktop using the terminate client method and the Desktops ID.
client = EPICClient("your_api_token_goes_here")
# Terminate desktop with ID 3
client.desktop.terminate(3)
client.desktops.terminate(3)
Teams
=====

.. code-block:: python
from pyepic import EPICClient
from pyepic.desktops import Desktop
client = EPICClient("your_api_token_goes_here")
# List teams
teams = client.teams.list()
for team in teams:
print(team)
# Get team ID 334
team = client.teams.get_details(334)
Projects
========

.. code-block:: python
from pyepic import EPICClient
from pyepic.desktops import Desktop
client = EPICClient("your_api_token_goes_here")
# List projects
projects = client.projects.list()
for project in projects:
print(project)
# Get project ID 102
project = client.projects.get_details(102)
16 changes: 16 additions & 0 deletions docs/source/pyepic.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ pyepic.client.job module
:undoc-members:
:show-inheritance:

pyepic.client.projects module
-----------------------------

.. automodule:: pyepic.client.projects
:members:
:undoc-members:
:show-inheritance:

pyepic.client.teams module
--------------------------

.. automodule:: pyepic.client.teams
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

Expand Down
1 change: 1 addition & 0 deletions pyepic/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .base import EPICClient

55 changes: 13 additions & 42 deletions pyepic/client/base.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,5 @@
import epiccore


class APIListResponse(object):
"""An abstract representation of the response from an EPIC API list request
"""

@property
def count(self):
"""
:return: Number of results returned
:rtype: int
"""
pass

@property
def next():
"""
:return next: The uri to get the next set of responses
:rtype: str
"""
pass

@property
def previous():
"""
:return next: The uri to get the previous set of responses
:rtype: str
"""
pass

@property
def results():
"""
:return: A list of the repsonse objects for request
:rtype: list
"""
pass


class Client(object):
"""Base client class for API wrappers
Expand All @@ -51,6 +13,7 @@ class Client(object):
def __init__(self, connection_token, connection_url="https://epic.zenotech.com/api/v2"):
"""Constructor method
"""
self.LIMIT = 10
self.configuration = epiccore.Configuration(
host=connection_url,
api_key={
Expand All @@ -71,8 +34,12 @@ class EPICClient(object):
:vartype job: :class:`JobClient`
:var catalog: API to Catalog functions
:vartype catalog: :class:`CatalogClient`
:var desktop: API to Desktops functions
:vartype desktop: :class:`DesktopClient`
:var desktops: API to Desktops functions
:vartype desktops: :class:`DesktopClient`
:var projects: API to Projects functions
:vartype projects: :class:`ProjectClient`
:var teams: API to Teams functions
:vartype teams: :class:`TeamsClient`
"""

def __init__(self, connection_token, connection_url="https://epic.zenotech.com/api/v2"):
Expand All @@ -81,7 +48,11 @@ def __init__(self, connection_token, connection_url="https://epic.zenotech.com/a
from .job import JobClient
from .catalog import CatalogClient
from .desktop import DesktopClient

from .projects import ProjectClient
from .teams import TeamsClient

self.job = JobClient(connection_token, connection_url=connection_url)
self.catalog = CatalogClient(connection_token, connection_url=connection_url)
self.desktop = DesktopClient(connection_token, connection_url=connection_url)
self.desktops = DesktopClient(connection_token, connection_url=connection_url)
self.projects = ProjectClient(connection_token, connection_url=connection_url)
self.teams = TeamsClient(connection_token, connection_url=connection_url)
Loading

0 comments on commit b59090e

Please sign in to comment.