Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-grid5000
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
SIMONIN Matthieu
python-grid5000
Commits
cd335507
Verified
Commit
cd335507
authored
5 years ago
by
SIMONIN Matthieu
Browse files
Options
Downloads
Patches
Plain Diff
fix doc
parent
4b33015e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.org
+59
-0
59 additions, 0 deletions
README.org
README.rst
+66
-4
66 additions, 4 deletions
README.rst
examples/timeseries.py
+2
-2
2 additions, 2 deletions
examples/timeseries.py
examples/vlan_set_2.py
+2
-2
2 additions, 2 deletions
examples/vlan_set_2.py
with
129 additions
and
8 deletions
README.org
+
59
−
0
View file @
cd335507
...
...
@@ -489,6 +489,65 @@ In [2]: # gk is your entry point
site.vlans[vlanid].submit({"nodes": nodes})
#+END_SRC
** Metrics API
*** Get some timeseries (and plot them)
For this example you'll need ~matplotlib~, ~seaborn~ and ~pandas~.
#+BEGIN_SRC python :exports code :tangle examples/timeseries.py
import logging
import os
from grid5000 import Grid5000
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import time
logging.basicConfig(level=logging.DEBUG)
conf_file = os.path.join(os.environ.get("HOME"), ".python-grid5000.yaml")
gk = Grid5000.from_yaml(conf_file)
metrics = gk.sites["lyon"].metrics
print("--- available metrics")
print(metrics.list())
print("---- power metric")
print(metrics["power"])
print("----- a timeserie")
now = time.time()
kwargs = {
"only": "nova-1,nova-2,nova-3",
"resolution": 1,
"from": int(now - 600),
"to": int(now)
}
timeseries = metrics["power"].timeseries.list(**kwargs)
# let's visualize this
df = pd.DataFrame()
for timeserie in timeseries:
print(timeserie)
timestamp = timeserie.timestamps
value = timeserie.values
measurement = timeserie.uid
df = pd.concat([df, pd.DataFrame({
"timestamp": timestamp,
"value": value,
"measurement": [measurement]*len(timestamp)
})])
sns.relplot(data=df,
x="timestamp",
y="value",
hue="measurement",
kind="line")
plt.show()
#+END_SRC
** More snippets
*** Site of a cluster
...
...
This diff is collapsed.
Click to expand it.
README.rst
+
66
−
4
View file @
cd335507
...
...
@@ -505,10 +505,72 @@ Before starting, the file ``$HOME/.python-grid5000.yaml`` will be loaded.
# set in vlan
site.vlans[vlanid].submit({"nodes": nodes})
4.8 More snippets
4.8 Metrics API
~~~~~~~~~~~~~~~
4.8.1 Get some timeseries (and plot them)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For this example you’ll need ``matplotlib``, ``seaborn`` and ``pandas``.
.. code:: python
import logging
import os
from grid5000 import Grid5000
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import time
logging.basicConfig(level=logging.DEBUG)
conf_file = os.path.join(os.environ.get("HOME"), ".python-grid5000.yaml")
gk = Grid5000.from_yaml(conf_file)
metrics = gk.sites["lyon"].metrics
print("--- available metrics")
print(metrics.list())
print("---- power metric")
print(metrics["power"])
print("----- a timeserie")
now = time.time()
kwargs = {
"only": "nova-1,nova-2,nova-3",
"resolution": 1,
"from": int(now - 600),
"to": int(now)
}
timeseries = metrics["power"].timeseries.list(**kwargs)
# let's visualize this
df = pd.DataFrame()
for timeserie in timeseries:
print(timeserie)
timestamp = timeserie.timestamps
value = timeserie.values
measurement = timeserie.uid
df = pd.concat([df, pd.DataFrame({
"timestamp": timestamp,
"value": value,
"measurement": [measurement]*len(timestamp)
})])
sns.relplot(data=df,
x="timestamp",
y="value",
hue="measurement",
kind="line")
plt.show()
4.9 More snippets
~~~~~~~~~~~~~~~~~
4.
8
.1 Site of a cluster
4.
9
.1 Site of a cluster
^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
...
...
@@ -536,7 +598,7 @@ Before starting, the file ``$HOME/.python-grid5000.yaml`` will be loaded.
clusters.remove(matching[0])
print("We found the following matches %s" % matches)
4.
8
.2 Get all job with a given name on all the sites
4.
9
.2 Get all job with a given name on all the sites
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
...
...
@@ -577,7 +639,7 @@ Before starting, the file ``$HOME/.python-grid5000.yaml`` will be loaded.
for job in jobs:
job.delete()
4.
8
.3 Caching API responses
4.
9
.3 Caching API responses
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Grid’5000 reference API is static. In this situation to speed up the
...
...
This diff is collapsed.
Click to expand it.
examples/timeseries.py
+
2
−
2
View file @
cd335507
...
...
@@ -28,9 +28,9 @@ kwargs = {
"
from
"
:
int
(
now
-
600
),
"
to
"
:
int
(
now
)
}
timeseries
=
metrics
[
"
power
"
].
timeseries
.
list
(
**
kwargs
)
# let's visualize this
timeseries
=
metrics
[
"
power
"
].
timeseries
.
list
(
**
kwargs
)
df
=
pd
.
DataFrame
()
for
timeserie
in
timeseries
:
print
(
timeserie
)
...
...
@@ -48,4 +48,4 @@ sns.relplot(data=df,
y
=
"
value
"
,
hue
=
"
measurement
"
,
kind
=
"
line
"
)
plt
.
show
()
\ No newline at end of file
plt
.
show
()
This diff is collapsed.
Click to expand it.
examples/vlan_set_2.py
+
2
−
2
View file @
cd335507
...
...
@@ -11,7 +11,7 @@ logging.basicConfig(level=logging.DEBUG)
def
_to_network_address
(
host
,
interface
):
"""
Translate a host to a network address
e.g:
para
vance
-20.rennes.grid5000.fr -> para
vance
-20-eth2.rennes.grid5000.fr
para
noia
-20.rennes.grid5000.fr -> para
noia
-20-eth2.rennes.grid5000.fr
"""
splitted
=
host
.
split
(
'
.
'
)
splitted
[
0
]
=
splitted
[
0
]
+
"
-
"
+
interface
...
...
@@ -26,7 +26,7 @@ site = gk.sites["rennes"]
job
=
site
.
jobs
.
create
({
"
name
"
:
"
pyg5k
"
,
"
command
"
:
"
sleep 3600
"
,
"
resources
"
:
"
{type=
'
kavlan
'
}/vlan=1+{cluster=
'
para
vance
'
}nodes=1
"
,
"
resources
"
:
"
{type=
'
kavlan
'
}/vlan=1+{cluster=
'
para
noia
'
}nodes=1
"
,
"
types
"
:
[
"
deploy
"
]
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment