Package: oar-lib
Python OAR Common LibraryPython version of OAR Common LibraryFree software: BSD licenseDocumentation:https://oar-lib.readthedocs.org.Read Configuration>>> from oar import config
>>>
>>> config.load_file("/path/to/config")
True
>>> config["ENERGY_SAVING_INTERNAL"]
'no'
>>> config.get_namespace('OARSUB_')
{'default_resources': '/resource_id=1', 'force_job_key': 'no', 'nodes_resources': 'network_address'}Query the database>>> from oar import db, Resource
>>> db
<Database engine=None>>>> db.query(Resource).first()
<oar.models.Resource object at 0x2becb10>
>>> Resource.query.first()
<oar.models.Resource object at 0x2becb10>>>> db
<Database engine=Engine(postgresql://oar:***@server:5432/oar)>>>> for r in Resource.query.filter(Resource.core > 3).limit(2):
...     print(r.id, r.network_address)
...
(12L, u'node3')
(9L, u'node3')>>> req = db.query(Resource.id, Resource.network_address)
>>> req.filter(Resource.core > 3).limit(2).all()
[(12L, u'node3'), (9L, u'node3')]LoggerLogging from the root logger:>> from oar import logger as log
>> log.info("Init confiuration")
## [INFO] [2014-12-05 14:13:42,239] [oar]: Init confiurationLogging from your own sublogger:>> from oar import get_logger
>> log = get_logger("oar.kao")
>> log.error("fatal error")
## [ERROR] [2014-12-05 14:14:32,116] [oar.kao]: fatal errorOAR lib changesVersion 0.4.1Released on September 30th 2015[all] Switched the license to BSD[all] Dropped python 3.3 support[all] Little code refactoring[database] Supported session read-only mode via oar_reader user[database]engine.executeis not used directly anymore, prefersession.execute[database] Used the same database connection with alembic and sqlalchemy[database] Added ephemeral session context manager that will rollback the transaction at the end[database] Addeddb.show()method to quickly show the database content[database] Used truncate instead of delete on postgresql indb.delete_all()[database]db.close()method closes the session and disposes the engine[database] Fixeddb.closemethod by removing deadlock[database] RaisedKeyErrorexception fromDatabaseif wantedModelorTableare missing[database] Configured automatically default table args withDeclarativeMetaclass[database] CreatedDeferredReflectionModelmetaclass perDatabaseinstance to avoid conflict during database reflection[database] Collected declared tables and models when they are defined[database] Avoided circular import of db object[database] Generated a tablename if none specified[models] The__repr__method inModelclasses include the identity of the object (primary key)[models] Set columnResource.scheduler_prioritytoBigInteger[models] AddedBaseModel.to_json method()method to convert a sqlalchemy entity to json[models] AddedBaseModel.to_dict()method to convert a sqlalchemy entity to a dictionary[models] FixedBaseModel.create()method[utils] Added ability to run command without timeout[utils] Used decimal module to check if input is a number[utils] ResetResultProxyIteriterator automatically[utils] FixedResultProxyIterrowcount[utils] Resetcached_propertyattribut when deleted[utils] Addedmerge_dicts()that merge given dictionaries into a new dictionary[basequery] UpdatedQuery.render()method to return a special string that have useful__repr__[basequery] AddedBaseQuery.get_jobs_for_user()query[test] Tested on postgresql and sqlite-file/memory with tox and travis.ci[test] Added test helper scripts to populate database[test] Fixed tests on python 3.4[test] More tests[compat] Removed unusedSimpleNamespaceclass from compat moduleVersion 0.3.0Released on July 07th 2015[database] FixedDatabase.delete_allmethod to remove all database content[database] Listed all datetime columns inmodels.TIME_COLUMNS[database] Made table and model import easier with getitem syntax (Eg. db[‘table_name’])[database] Added an alembic operator asDatabase.opattribut[database] Kept columns order during dictionary conversion[database] Put MySQLdb SSCursor tweak on standby[models] AddedResultProxyIterclass that make SQLAlchemy ResultProxies iterable by dicts[models] Fixed columns orders for admission_rules table[models]models.all_tablesreturns a dictionary with table names as keys now[models] Forwarded log to STDOUT ifget_logger(..)receivestdout=True[configuration] New default configuration values forDB_PORT=5432andDB_TYPE=Pg[configuration] HandledOARCONFFILEenvironment variable to load OAR configuration[basequery] AddedQuery.renderthat generate an SQL expression string from statement[basequery] Addedget_gantt_visu_scheduled_jobs_resourcesmethod that returns all nodes allocated to a (waiting) reservation[basequery] Addedget_assigned_jobs_resourcesand groups results by job_id[basequery] Optimized get_user_jobs query by using JOIN instead of IN operator[basequery] Loaded only some columns with Load ORM object[utils] Addedutils.Commandclass to run subprocess commands with a timeout option[utils] MovedJSONEncoderclass from oar-rest-api to oar-lib[utils] Removed unsedIterStreamclass[utils] Addedutils.row2dictfunction helpers to convert a RowProxy to a dict[compat] Used simplejson if availableVersion 0.2.0Released on June 23rd 2015[config] Added clear parameter to clear the config before loading a new file[config] only one default configuration file[config] Made load file configuration atomic[config] Warned user when configuration loading failed[compat] Used iterator version of zip and range method[compat] Removed unused string_types[database] pg_bulk_insert that use COPY clause to perform batch inserts[database] Added db.queries object that included all oar-lib sql queries[database] Workaround to support table inheritance and __table_args__[database] Moved the BaseQuery class to the basequery module[models] Added missings relations between tables as dicts[models] Used BigInteger type on Accounting fields[models] Added all_tables method to get all tables[basequery] make models module easier to read[basequery] Added get_job_resources query[basequery] Added filter_jobs_for_user method to build jobs query[basequery] Added get_resources[basequery] Added get_jobs_for_user query[utils] Added IterStream class that give a stream like interface for any iteratorAdded alembic and sqlalchemy-utils requirementsVersion 0.1.1Released on April 30th 2015Minor bugfixesVersion 0.1.0Released on April 21st 2015First public release of oar-lib