-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.0 - Script Writing Class #62
Comments
I think this is reasonable. I still think you'll want to break out the parts of the scheduler that apply each piece into separate methods though. It may not make sense now, but later when you need to override just the part that designates the header, writes the post cmds, or whatever, you'll be happy it's in small steps. |
In an effort to keep this class as general as possible, I'm going to leave the scheduler-specifics to whatever calls this class and populates it's fields. |
Implementation concept: class scriptComposer():
"""Class to compose a bash or batch script for use by Pavilion."""
def setHeader( ... ):
"""Function to set the header values for the script.
:param string shell_path: Shell path specification. Typically '/bin/bash'. default = None.
:param dict scheduler_macros: Scheduler macros. If there are elements that are only one entry, the value will just be None. default = None.
"""
def setModules( ... ):
"""Function to set the modules section for the script.
:param list explicit_specification: List of commands to manage the modules explicitly. default = None.
:param bool purge: Whether or not module purge will work on this machine. default = False
:param list unloads: List of modules to unload for the script. default = None.
:param list loads: List of modules to load for the script. default = None.
:param dict swaps: Dictionary of modules to swap. The current module should be the key and the module to replace it with should be the value. default = None.
"""
def setEnvironment( ... ):
"""Function to set and unset the environment variables.
:param dict set_env: Dictionary of environment variables to set where the key is the environment variable and the value is the value assigned to that variable. default = None
:param list unset_env: List of environment variables to unset for the script. default = None
"""
def setCommands( ... ):
"""Function to specify the commands for the script.
:param list commands: List of strings specifying the script commands in order. default = None
"""
def setPost( ... ):
"""Function to specify the commands to run at the end of the script for generic tasks.
:param list commands: List of strings specifying the postscript commands in order. default = None
"""
def setDetails( ... ):
"""Function to set the final details of the script.
:param string script_name: Specify a name for the script. default = 'pav_(date)_(time)'
:param string script_type: Type of script, determining an appropriate file ending. default = bash
:param string user: Name of user to set as owner of the file. default = current user
:param string group: Name of group to set as owner of the file. default = user default group
:param int owner_perms: Value for owner's permission on the file (see `man chmod`). default = 7
:param int group_perms: Value for group's permission on the file (see `man chmod`). default = 5
:param int world_perms: Value for the world's permission on the file (see `man chmod`). default = 0
"""
def writeScript():
"""Function to write the script out to file.
:return bool result: Returns either True for successfully writing the file or False otherwise.
""" Thoughts, @pflarr ? |
I'd changes all the those to getter/setter methods. Then you can just say scriptwriter.post = lines |
This class should provide the mechanisms for generating a script for use in various parts of Pavilion. It will provide the mechanism for writing the scheduler batch scripts (or bash script if running in 'raw' mode), the scripts for building the tests, and the scripts for running the tests. The basic components will include:
Each section should accept a dictionary, list, or string as appropriate.
The text was updated successfully, but these errors were encountered: