Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
simso
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7fdd18fa
authored
Jul 01, 2015
by
Josué A
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'scheduler' decorator to register schedulers and their parameters
parent
516a7b63
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
simso/schedulers/__init__.py
+51
-0
No files found.
simso/schedulers/__init__.py
View file @
7fdd18fa
# List of all schedulers that have been declared using
# the @scheduler decorator.
__loaded_schedulers
=
[]
# Decorator used to register a scheduler to be returned by get_declared_schedulers()
def
scheduler
(
name
,
**
kwargs
):
"""
Decorator used to register a scheduler to be returned by get_declared_schedulers().
Mandatory arguments :
name : the complete name of the scheduler (ex : simso.schedulers.EDF)
Optional keyword arguments :
display_name : name to be shown to the user
required_fields : list of required fields for this scheduler to work correctly.
It should be a dict with the following keys :
name: name of the field
type: type of the field
default: default value of the field
required_task_fields : list of required fields for this scheduler's tasks
to work correctly. Same format as required_fields
required_proc_fields : list of required fields for this scheduler's processors
to work correctly. Same format as required_fields
The list of registered schedulers is mostly used in graphical interfaces to auto-detect
the exposed schedulers.
"""
required_fields
=
kwargs
[
'required_fields'
]
if
'required_fields'
in
kwargs
else
[]
task_f
=
kwargs
[
'required_task_fields'
]
if
'required_task_fields'
in
kwargs
else
[]
proc_f
=
kwargs
[
'required_proc_fields'
]
if
'required_proc_fields'
in
kwargs
else
[]
display_name
=
kwargs
[
'display_name'
]
if
'display_name'
in
kwargs
else
name
def
f
(
klass
):
# Note :
# We didn't include this data into the classes because it didn't work
# properly with inheritance.
# klass.simso_name = name
# klass.simso_required_fields = required_fields
# klass.simso_required_task_fields = task_f
# klass.simso_required_proc_fields = proc_f
__loaded_schedulers
.
append
({
'name'
:
name
,
'display_name'
:
display_name
,
'required_fields'
:
required_fields
,
'required_task_fields'
:
task_f
,
'required_proc_fields'
:
proc_f
})
return
klass
return
f
def
get_loaded_schedulers
():
return
__loaded_schedulers
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment