Commit 29c77a38 authored by payno's avatar payno

Merge branch 'modif_henri' into 'master'

Modif henri

See merge request !1
parents fc64d266 a6babab0
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# pycharm stuff
.idea/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
The silx toolkit is a software library and one of its goals is not to impose any license to the end user.
Silx follows the permissive MIT license although it may include contributions following other licenses not interfering with the previous goal. Detailed information can be found in the copyright file.
Silx uses the Qt library for its graphical user interfaces.
A word of caution is to be provided.
If users develop and distribute software using modules accessing Qt by means of Riverbank Computing Qt bindings PyQt4 or PyQt5, those users will be conditioned by the license of their PyQt4/5 software (GPL or commercial).
If the end user does not own a commercial license of PyQt4 or PyQt5 and wishes to be free of any distribution condition, (s)he should be able to use PySide2 because it uses the LGPL license.
The MIT license follows:
Copyright (c) European Synchrotron Radiation Facility (ESRF)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -10,9 +10,9 @@ Hello world (minimal):
from oarpy import oarjob
jobdef = oarjob.JobDefinition(command='echo "Hello word"')
jobdef = oarjob.JobFactory(command='echo "Hello word"')
job = jobdef.submit()
job.wait_finished()
job.wait()
if job.exit_code:
print('Failed:\n{}'.format(job.stderr))
......@@ -30,14 +30,14 @@ Hello world (specify resources and postpone execution):
from oarpy.oarresource import Resource
resource = Resource(core=2,walltime={'hours':2},gpu=True)
jobdef = oarjob.JobDefinition(name='helloworld',project='oarpy',
jobdef = oarjob.JobFactory(name='helloworld',project='oarpy',
command='echo "Hello word"',resource=resource)
job = jobdef.submit(hold=True)
job.wait_needsresume()
job.wait(states=('Hold', 'Suspended'))
# job is waiting for you to resume it
job.resume()
job.wait_finished()
job.wait()
if job.exit_code:
print('Failed:\n{}'.format(job.stderr))
......
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = oarpy
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=python -msphinx
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=oarpy
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
echo.then set the SPHINXBUILD environment variable to point to the full
echo.path of the 'sphinx-build' executable. Alternatively you may add the
echo.Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# oarpy documentation build configuration file, created by
# sphinx-quickstart on Mon Nov 19 09:33:29 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'oarpy'
copyright = '2018, de nolf'
author = 'de nolf'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'classic'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
# html_sidebars = {
# '**': [
# 'about.html',
# 'navigation.html',
# 'relations.html', # needs 'show_related': True theme option to display
# 'searchbox.html',
# 'donate.html',
# ]
# }
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'oarpydoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'oarpy.tex', 'oarpy Documentation',
'de nolf', 'manual'),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'oarpy', 'oarpy Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'oarpy', 'oarpy Documentation',
author, 'oarpy', 'One line description of project.',
'Miscellaneous'),
]
.. oarpy documentation master file, created by
sphinx-quickstart on Mon Nov 19 09:33:29 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to oarpy's documentation!
=================================
.. toctree::
:maxdepth: 2
:caption: Contents:
modules.rst
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
oarpy
=====
.. toctree::
:maxdepth: 4
oarpy
oarpy package
=============
Subpackages
-----------
.. toctree::
oarpy.tests
Submodules
----------
oarpy\.oarjob module
--------------------
.. automodule:: oarpy.oarjob
:members:
:undoc-members:
:show-inheritance:
oarpy\.oarresource module
-------------------------
.. automodule:: oarpy.oarresource
:members:
:undoc-members:
:show-inheritance:
oarpy\.oarshell module
----------------------
.. automodule:: oarpy.oarshell
:members:
:undoc-members:
:show-inheritance:
oarpy\.timeutils module
-----------------------
.. automodule:: oarpy.timeutils
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: oarpy
:members:
:undoc-members:
:show-inheritance:
oarpy\.tests package
====================
Submodules
----------
oarpy\.tests\.test\_all module
------------------------------
.. automodule:: oarpy.tests.test_all
:members:
:undoc-members:
:show-inheritance:
oarpy\.tests\.test\_oarjob module
---------------------------------
.. automodule:: oarpy.tests.test_oarjob
:members:
:undoc-members:
:show-inheritance:
oarpy\.tests\.test\_oarresource module
--------------------------------------
.. automodule:: oarpy.tests.test_oarresource
:members:
:undoc-members:
:show-inheritance:
oarpy\.tests\.test\_oarshell module
-----------------------------------
.. automodule:: oarpy.tests.test_oarshell
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: oarpy.tests
:members:
:undoc-members:
:show-inheritance:
......@@ -8,8 +8,8 @@
"------------------------------------------------\n",
"Three classes are used\n",
"* oarpy.oarjob.Job: manage existing jobs (status, stop, suspend, resume)\n",
"* oarpy.oarjob.JobDefinition: define and launch jobs (creates oarpy.oarjob.Job)\n",
"* oarpy.oarresource.Resource: optional OAR resources for JobDefinition (nodes, cores, gpu)"
"* oarpy.oarjob.JobFactory: define and launch jobs (creates oarpy.oarjob.Job)\n",
"* oarpy.oarresource.Resource: optional OAR resources for JobFactory (nodes, cores, gpu)"
]
},
{
......@@ -121,10 +121,10 @@
" # Statistics exposed as attributes\n",
" # Context manager is optional\n",
" with job.fixed_stats():\n",
" assert(job.finished)\n",
" assert(not job.running)\n",
" assert(not job.waiting)\n",
" assert(not job.intermediate)\n",
" assert(job.is_finished)\n",
" assert(not job.is_running)\n",
" assert(not job.is_waiting)\n",
" assert(not job.is_intermediate)\n",
" assert(not job.needsresume)\n",
" assert(job['state']==job.status)"
]
......@@ -152,7 +152,7 @@
}
],
"source": [
"jobdef = oarjob.JobDefinition(command=\"ls\")\n",
"jobdef = oarjob.JobFactory(command=\"ls\")\n",
"print(jobdef)"
]
},
......@@ -177,7 +177,7 @@
}
],
"source": [
"jobdef = oarjob.JobDefinition(name='test',project='oarpy',command='ls')\n",
"jobdef = oarjob.JobFactory(name='test',project='oarpy',command='ls')\n",
"print(jobdef)"
]
},
......@@ -202,8 +202,8 @@
}
],
"source": [
"jobdef = oarjob.JobDefinition(name='test',project='oarpy',command='ls',\n",
" working_directory='/tmp/oarpy',log_directory='/tmp/oarpy/log')\n",
"jobdef = oarjob.JobFactory(name='test',project='oarpy',command='ls',\n",
" working_directory='/tmp/oarpy',log_directory='/tmp/oarpy/log')\n",
"print(jobdef)"
]
},
......@@ -239,8 +239,8 @@
],
"source": [
"resource = Resource(nodes=1,core=8,walltime={'minutes':1})\n",
"jobdef = oarjob.JobDefinition(name='test',project='oarpy',\n",
" command='ls',resource=resource)\n",
"jobdef = oarjob.JobFactory(name='test',project='oarpy',\n",
" command='ls',resource=resource)\n",
"print(jobdef)"
]
},
......@@ -262,8 +262,8 @@
"def definition(seconds):\n",
" command = 'python -c \"from time import sleep\\nfor i in range({}):\\n print(i)\\n sleep(1)\"'\n",
" resource = Resource(core=1,walltime={'seconds':seconds*3})\n",
" return oarjob.JobDefinition(name='test{}'.format(seconds),project='oarpy',\n",
" resource=resource,command=command.format(seconds))"
" return oarjob.JobFactory(name='test{}'.format(seconds),project='oarpy',\n",
" resource=resource,command=command.format(seconds))"
]
},
{
......@@ -315,7 +315,7 @@
" job = definition(5).submit()\n",
" print(job)\n",
" print(\"Wait until finished ...\")\n",
" job.wait_finished()\n",
" job.wait()\n",
" print(job)\n",
" if job.exit_code:\n",
" print('Failed:\\n{}'.format(job.stderr))\n",
......@@ -382,12 +382,12 @@
" job = definition(5).submit(hold=True)\n",
" print(job)\n",
" print(\"Wait until enqueued ...\")\n",
" job.wait_needsresume()\n",
" job.wait(states=('Hold', 'Suspended'))\n",
" print(job)\n",
" print(\"Schedule job\")\n",
" job.resume()\n",
" print(\"Wait until finished ...\")\n",
" job.wait_finished()\n",
" job.wait()\n",
" print(job)\n",
" if job.exit_code:\n",
" print('Failed:\\n{}'.format(job.stderr))\n",
......@@ -525,7 +525,7 @@
" job = definition(60).submit()\n",
" print(job)\n",
" print(\"Wait until started ...\")\n",
" job.wait_started()\n",
" job.wait(states=('Running', 'Terminated', 'Error')\n",
" print(job)\n",
" print(\"Suspend job\")\n",
" try:\n",
......@@ -534,12 +534,12 @@
" print(\"This operation is currently not permitted\")\n",
" else:\n",
" print(\"Wait until suspended ...\")\n",
" job.wait_needsresume()\n",
" job.wait_needsresume(states=('Hold', 'Suspended'))\n",
" print(job)\n",
" print(\"Resume job\")\n",
" job.resume()\n",
" print(\"Wait until finished ...\")\n",
" job.wait_finished()\n",
" job.wait()\n",
" print(job)\n",
" if job.exit_code:\n",
" print('Failed:\\n{}'.format(job.stderr))\n",
......@@ -595,12 +595,12 @@
" job = definition(60).submit()\n",
" print(job)\n",
" print(\"Wait until started ...\")\n",
" job.wait_started()\n",
" job.wait(states=('Running', 'Terminated', 'Error'))\n",
" sleep(5)\n",
" print(\"Interrupt\")\n",
" job.interrupt()\n",
" print(\"Wait until finished ...\")\n",
" job.wait_finished()\n",
" job.wait()\n",
" print(job)\n",
" if job.exit_code:\n",
" print('Failed:\\n{}'.format(job.stderr))\n",
......
......@@ -16,19 +16,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"........\n",
"Succes:\n",
"Hello word\n",
"\n"
".......\n",
"Interrupted:\n",
"None\n"
]
}
],
"source": [
"from oarpy import oarjob\n",
"\n",
"jobdef = oarjob.JobDefinition(command='echo \"Hello word\"')\n",
"jobdef = oarjob.JobFactory(command='echo \"Hello word\"')\n",
"job = jobdef.submit()\n",
"job.wait_finished()\n",
"job.wait()\n",
"\n",
"if job.exit_code:\n",
" print('Failed:\\n{}'.format(job.stderr))\n",
......@@ -67,14 +66,14 @@
"from oarpy.oarresource import Resource\n",
"\n",
"resource = Resource(core=1,walltime={'hours':1},gpu=False)\n",
"jobdef = oarjob.JobDefinition(name='helloworld',project='oarpy',\n",
"jobdef = oarjob.JobFactory(name='helloworld',project='oarpy',\n",
" command='echo \"Hello word\"',resource=resource)\n",
"\n",
"job = jobdef.submit(hold=True)\n",
"job.wait_needsresume()\n",
"job.wait(states=('Hold', 'Suspended'))\n",
"# job is waiting for you to resume it\n",
"job.resume()\n",
"job.wait_finished()\n",
"job.wait()\n",
"\n",
"if job.exit_code:\n",
" print('Failed:\\n{}'.format(job.stderr))\n",
......@@ -192,14 +191,14 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
......
This diff is collapsed.
......@@ -21,33 +21,42 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
__authors__ = ["W. De Nolf"]
__license__ = "MIT"
import datetime
import re
from . import oarshell
def walltime2str(tdelta):
h, rem = divmod(int(round(tdelta.total_seconds())), 3600)
m, s = divmod(rem, 60)
return '{:02d}:{:02d}:{:02d}'.format(h,m,s)
return '{:02d}:{:02d}:{:02d}'.format(h, m, s)
def str2walltime(s):
h,m,s = s.split(':')
h, m, s = s.split(':')
return datetime.timedelta(hours=int(h), minutes=int(m), seconds=int(s))
class Resource(object):
def __init__(self,host=None,nodes=None,cpu=None,core=None,gpu=False,
walltime=None,mem_core_mb=None):
def __init__(self, host=None, nodes=None, cpu=None, core=None, gpu=False,
walltime=None, mem_core_mb=None):
"""
Args:
host(Optional(int)): number of hosts to be used
nodes(Optional(int)): number of nodes to be used
cpu(Optional(int)): number of cpu's per node
core(Optional(int)): number of cores per cpu
gpu(Optional(bool)): need a gpu or not
walltime(Optional(timedelta|dict|num)): hours when a number