diff --git a/README.org b/README.org new file mode 100644 index 0000000000000000000000000000000000000000..98e7ed3281804d6761d1aa5d4ec3dee1411d6893 --- /dev/null +++ b/README.org @@ -0,0 +1,95 @@ +#+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~. + + diff --git a/examples/job_submission.py b/examples/job_submission.py new file mode 100644 index 0000000000000000000000000000000000000000..ba778e1cc59043453e9b9c028c5e5d9f3ff43d15 --- /dev/null +++ b/examples/job_submission.py @@ -0,0 +1,21 @@ +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) diff --git a/examples/node_information.py b/examples/node_information.py new file mode 100644 index 0000000000000000000000000000000000000000..a922bf00f8eca1ca4c66f7719848913800f064f8 --- /dev/null +++ b/examples/node_information.py @@ -0,0 +1,13 @@ +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"])) diff --git a/examples/storage_accesses.py b/examples/storage_accesses.py new file mode 100644 index 0000000000000000000000000000000000000000..2e6ceeea7f2c6af54441ac02bd905223f7e1886b --- /dev/null +++ b/examples/storage_accesses.py @@ -0,0 +1,10 @@ +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())