Mentions légales du service

Skip to content
Snippets Groups Projects
Verified Commit 89cdfda9 authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

Update README + exemples

parent d0900bf1
No related branches found
No related tags found
No related merge requests found
Pipeline #65311 passed
#+TITLE: python-grid5000
#+AUTHOR: Matthieu Simonin
#+EMAIL: {firstname.lastname}@inria.fr
#+LANGUAGE: en
#+OPTIONS: ':t author:nil email:nil date:nil toc:nil
#+PROPERTY: header-args:sh :eval no
#+PROPERTY: header-args:sh+ :comments org
~python-grid5000~ is a python package wrapping the Grid'5000 REST API.
#+BEGIN_warning
The code is currently being developed heavily.
#+END_warning
* Thanks
The core code is borrowed from [[https://github.com/python-gitlab/python-gitlab][python-gitlab]] with small adaptations to
conform with Grid5000 API models (with an 's'!)
* Examples
** Submit a job
#+BEGIN_SRC python :tangle examples/job_submission.py
import json
import time
from grid5000 import Grid5000
gk = Grid5000.from_yaml("~/.python-grid5000.yaml")
site = gk.sites["rennes"]
job = site.jobs.create({
"name":"pyg5k",
"command": "sleep 3600",
})
while job.state != "running":
job.refresh()
print("Waiting the job to start")
time.sleep(10)
print(job)
print("Assigned nodes : %s" % job.assigned_nodes)
#+END_SRC
** Get node information
#+BEGIN_SRC python :tangle examples/node_information.py
import json
import os
import time
from grid5000 import Grid5000
conf_file = os.path.join(os.environ.get("HOME"), ".python-grid5000.yaml")
gk = Grid5000.from_yaml(conf_file)
node_info = gk.sites["nancy"].clusters["grisou"].nodes["grisou-1"]
print("grisou-1 has {threads} threads and has {ram} bytes of RAM".format(
threads=node_info.architecture["nb_threads"],
ram=node_info.main_memory["ram_size"]))
#+END_SRC
** Get Storage accesses
#+BEGIN_SRC python :tangle examples/storage_accesses.py
import json
import os
import time
from grid5000 import Grid5000
conf_file = os.path.join(os.environ.get("HOME"), ".python-grid5000.yaml")
gk = Grid5000.from_yaml(conf_file)
print(gk.sites["rennes"].storage["msimonin"].access.list())
#+END_SRC
* Appendix :noexport:
** How to export this file
- Produce ~README.rst~.
To generate the rst file, load the ~ox-rst.el~ file from
https://github.com/msnoigrs/ox-rst into emacs. Then do, ~C-c C-e r r~ or ~M-x
org-rst-export-to-rst~.
- Produce python example scripts.
Do ~C-c C-v t~ or ~M-x
org-babel-tangle~. The scripts are available under available under ~examples~.
import json
import time
from grid5000 import Grid5000
gk = Grid5000.from_yaml("~/.python-grid5000.yaml")
site = gk.sites["rennes"]
job = site.jobs.create({
"name":"pyg5k",
"command": "sleep 3600",
})
while job.state != "running":
job.refresh()
print("Waiting the job to start")
time.sleep(10)
print(job)
print("Assigned nodes : %s" % job.assigned_nodes)
import json
import os
import time
from grid5000 import Grid5000
conf_file = os.path.join(os.environ.get("HOME"), ".python-grid5000.yaml")
gk = Grid5000.from_yaml(conf_file)
node_info = gk.sites["nancy"].clusters["grisou"].nodes["grisou-1"]
print("grisou-1 has {threads} threads and has {ram} bytes of RAM".format(
threads=node_info.architecture["nb_threads"],
ram=node_info.main_memory["ram_size"]))
import json
import os
import time
from grid5000 import Grid5000
conf_file = os.path.join(os.environ.get("HOME"), ".python-grid5000.yaml")
gk = Grid5000.from_yaml(conf_file)
print(gk.sites["rennes"].storage["msimonin"].access.list())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment