HPS API#
This section documents GLOW’s HPS API which enable transaction methods to start HPS jobs and parametric studies and request data from those jobs and studies.
- class ansys.saf.glow.solution.hps.HpsComputeResourceSet(*, name: str, queues: list[HpsQueue])#
Bases:
BaseModelA compute resource set in HPS.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ansys.saf.glow.solution.hps.HpsDesignPointSelection(required_design_points: list[int] | None = None, eval_status: HpsJobEvaluationStatus | list[HpsJobEvaluationStatus] | None = None, limit: int | None = None, offset: int | None = None, sort: str | list[str] | None = None, parameter_filter: dict[str, str | int | float | list[str | int | float]] | None = None)#
Bases:
objectA selector of design points in a
HpsParametricStudyProject. Therequired_design_points,eval_statusandparameter_filterarguments, when present, combine to define a base set of design points. This base set can then be sorted via thesortargument. The base set is then further restricted by thelimitandoffsetarguments.- Parameters:
- required_design_points
list[int] |None,optional Specifies the indices of the design points to be included in the selection. Default is None which means all design points are included.
- eval_status
HpsJobEvaluationStatus|list[HpsJobEvaluationStatus] |None,optional Specifies the evaluation status of the design points to be included in the selection. if a list is provided then design points with any of the specified statuses are included. Default is None which means all design points are included.
- limit
int|None,optional Specifies the maximum number of design points to be included in the selection. Default is None which means all design points are included.
- offset
int|None,optional Specifies the number of design points to skip before including design points in the selection. Default is None which means no design points are skipped.
- sort
str|list[str] |None,optional Specifies the keys of the parameters to sort the design points by. Default is None which means the design points are only sorted by the order passed to
start_hps_parametric_study().- parameter_filter
dict[str,str|int|float|list[str|int|float]] |None,optional Specified a filter based on parameter values. Default is None which means all design points are included.
An entry key string relates a parameter to the entry value to form a filter. The entries in the dictionary are combined to filter the design points. A design point must meet the criteria of all dictionary entries to be included.
The values of the dictionary are either parameter values or lists of parameter values. Parameter values are either strings, integers or floats. The keys are either the name of a parameter or a string of the form
<parameter_name>.<operator>. Valid operator substrings are:=- equal tone- not equal tolt- less thanle- less than or equal togt- greater thange- greater than or equal toin- in a list of valuescontains- contains value as substring
If the name of the parameter is used alone in the key then the relationship is “equal to” if the value is not a list and “in” if the value is a list.
For example an entry with key
"temperature.gt"and value100would only include design points where the temperature parameter is greater than 100.
- required_design_points
- class ansys.saf.glow.solution.hps.HpsExecutionSpecification(function: Callable[[...], Any] | str, output_parameters: dict[str, type | HpsOutputFileSpecification | HpsOutputDirectorySpecification], module: ModuleType | Path | None = None, max_execution_time: float = 604800, resource_requirements: ResourceRequirements | None = None, dependencies: list[str] | None = None, python_version: str | None = None, products: list[Software] | None = None, use_ansys_python: bool = False, hps_server_url: str | None = None)#
Bases:
objectSpecification of a HPS job or parametric study.
- Parameters:
- function: Callable[…, Any] | str
The function to be executed in the HPS job or parametric study or a string referring to a function. The string is of the form
<module_name>.<function_name>- output_parameters
dict[str,type|HpsOutputFileSpecification|HpsOutputDirectorySpecification] This argument specifies the required output parameters, files and directories. Each item represents either an output parameter, an output file or an output directory. The key is the name of the parameter, file or directory in HPS.
HpsOutputFileSpecificationvalues are used to represent output files andHpsOutputDirectorySpecificationvalues are used to represent output directories, (HPS parameters are not created for them). Pythontypevalues are used to represent HPS output parameters.- module: ModuleType | Path, optional
The module that needs to be transferred to HPS to ensure that the function can be executed. The module must include
function. By default the source code transferred to HPS for execution is the content of thescriptsdirectory located in the directory containing the step definition module that contains the transaction method that callsexecute. Ifmoduleis aPathobject then it should refer to a file or directory in the solution source tree where the path is relative to the root of the solution source tree. For example if you want to ensure the directory<your solution>/src/ansys/solutions/fastcar/simulationis transferred to HPS then you can passPath("ansys/solutions/fastcar/simulation")as themoduleargument.- max_execution_time: float, optional
The maximum execution time of each job in seconds. The default is one week.
- resource_requirements: ResourceRequirements, optional
The resource requirements of each job. Uses HPS default values when values are not provided.
- dependencies: list[str], optional
A list of pip requirement specifier strings indicating the python packages that are required to evaluate a design point. Use of this parameter will trigger the creation of a Python virtual environment for each design point and the design point evaluation will not use the SAF Product Environment virtual environment. Use the
python_versionparameter to specify the version of Python for the virtual environment. Thedependenciesargument does not determine what products and applications are available for design point evaluation, use theproductsargument for that purpose. See the corresponding section for details on specifying python package dependencies for jobs (the parametric study API is identical to the job API in this aspect: ‘job’ is equivalent to ‘design point evaluation’)- use_product_environment: bool, optional
Whether to use the SAF Product Environment virtual environment for design point evaluation. By default, the SAF Product Environment virtual environment is used if the
dependenciesargument is not set or is empty. By default, the SAF Product Environment virtual environment is not used if thedependenciesargument is set to a non-empty list.- python_version: str, optional
The version of Python to use for design point evaluation when the SAF Product environment is not used. The string is of the form “major.minor” where major and minor are integers. The default value is “3.11”.
- product_environment_version: str, optional
The version of the SAF Product Environment to use for design point evaluation. The format of the version string of a SAF Product Environment has not yet been determined.
- products: list[Software], optional
A list of products or applications required for design point evaluation. The list items must be of type
Software. The default value is an empty list. The list should not contain entries for python or the SAF Product Environment. See the corresponding section for details on specifying product requirements for jobs (the parametric study API is identical to the job API in this aspect: ‘job’ is equivalent to ‘design point evaluation’).- use_ansys_python: bool, optional
Whether to use Ansys Python instead of Python for the job when the SAF Product environment is not used. The selected Ansys Python version is determined by python_version. The default value is False.
- hps_server_url: str, optional
HPS endpoint that the HPS client will connect to.
- execute(**kwargs: Any) HpsSimpleProject#
Execute the specified function with the provided arguments.
- Parameters:
- **kwargs
Any The arguments to pass to the function. Arguments of the types
Path,EntityHandle`,HpsInputFileSpecificationandHpsInputDirectorySpecificationare treated as input files or directories. The referenced files and directories are transferred to HPS for job execution.Pathvalues are then passed to the job function referencing the files and directories in the HPS execution environment. All other arguments are passed unchanged to the job function.
- **kwargs
- execute_parametric_study(**kwargs: Any) HpsParametricStudyProject#
Execute a parametric study with the specified function and arguments.
- Parameters:
- **kwargs
Any The arguments to pass to the function. Arguments of the types
PathEntityHandle`,HpsInputFileSpecificationandHpsInputDirectorySpecificationare treated as input files or directories. The referenced files and directories are transferred to HPS for job execution.Pathvalues are then passed to the job function referencing the files and directories in the HPS execution environment. All other arguments must be list values. These lists must of the same length. Each combination of list values is used to create a design point for the parametric study.
- **kwargs
- class ansys.saf.glow.solution.hps.HpsInputDirectorySpecification(source: EntityHandle | Path, evaluation_path: str | None = None)#
Bases:
HpsInputSourceSpecification[Path|EntityHandle]The specification of a directory which will be used as input for a HPS job or parametric study.
- Parameters:
- source
EntityHandle|Path The source of the directory.
- evaluation_path
str|None,optional The relative path for the directory when it is copied into the current working directory of a HPS job. The default behaviour (indicated by argument
Nonevalue) is to copy the directory into the current working directory with same filename as the source directory
- source
- class ansys.saf.glow.solution.hps.HpsInputFileSpecification(source: T, evaluation_path: str | None = None)#
Bases:
HpsInputSourceSpecification[Path|EntityHandle]The specification of a file which will be used as input for a HPS job or parametric study.
- Parameters:
- source
Path The source of the file.
- evaluation_path
str|None,optional The relative path for the file when it is copied into the current working directory of a HPS job. The default behaviour (indicated by argument
Nonevalue) is to copy the file into the current working directory with same filename as the source file
- source
- class ansys.saf.glow.solution.hps.HpsJobEvaluationStatus(*values)#
Bases:
EnumThe states of a HPS Job.
- ABORTED = 'aborted'#
The job evaluation was aborted.
- EVALUATED = 'evaluated'#
The job has been successfully evaluated.
- FAILED = 'failed'#
The job evaluation failed.
- PENDING = 'pending'#
The job is waiting for an evaluator to evaluate the job.
- PROLOG = 'prolog'#
The job is being prepared for evaluation.
- RUNNING = 'running'#
The job is being evaluated.
- TIMEOUT = 'timeout'#
The job evaluation timed out.
- exception ansys.saf.glow.solution.hps.HpsJobValidationError#
Bases:
ExceptionAn exception raised when a HPS job is invalid and cannot be started.
- class ansys.saf.glow.solution.hps.HpsOutputDirectorySpecification(evaluation_path: str | None = None, monitor: bool = False, collect_interval: int = 0)#
Bases:
HpsOutputSourceSpecificationThe specification of a directory which will be generated by a HPS job.
- Parameters:
- evaluation_path
str|None,optional The relative path for the directory in the current working directory of a successfully completed HPS job. The default behaviour (indicated by argument
Nonevalue) is to expect the directory in the current working directory of a successfully completed HPS job with the directory’s key as its name. The directory’s key is the key of the entry containing theHpsOutputDirectorySpecificationobject in the dictionary passed as anoutput_parametersargument tostart_hps_job()orstart_hps_parametric_study().- monitorbool,
optional This flag determines whether the directory is monitored for changes by HPS. The default is False.
- collect_interval
int,optional Collection frequency for the directory, specified in seconds. The default is 0.
- evaluation_path
- class ansys.saf.glow.solution.hps.HpsOutputFileSpecification(evaluation_path: str | None = None, monitor: bool = False, collect_interval: int = 0)#
Bases:
HpsOutputSourceSpecificationThe specification of a file which will be generated by a HPS job.
- Parameters:
- evaluation_path
str|None,optional The relative path for the file in the current working directory of a successfully completed HPS job. The default behaviour (indicated by argument
Nonevalue) is to expect the file in the current working directory of a successfully completed HPS job with the file’s key as its filename. The file’s key is the key of the entry containing theHpsOutputFileSpecificationobject in the dictionary passed as anoutput_parametersargument tostart_hps_job()orstart_hps_parametric_study().- monitorbool,
optional This flag determines whether the file is monitored for changes by HPS. The default is False.
- collect_interval
int,optional Collection frequency for the file, specified in seconds. The default is 0.
- evaluation_path
- class ansys.saf.glow.solution.hps.HpsParametricStudyProject(*, hps_project_identifier: str = '', hps_server_url: str | None = None, client_id: str | None = None, file_parameters_using_handles: list[str] = [], pickled_parameters: list[str] = [])#
Bases:
HpsParametricStudyProjectBaseA reference to a parametric study project in HPS.
Notes
When instances of this class reference an HPS project they have attributes for the parameters and files of the project. The names of these attributes are those used for these entities in HPS and passed to
start_hps_parametric_study. The values of the attributes are lists of values for the parameters or files across the design points. The ordering of the lists corresponds to the ordering of the input parameters values passed tostart_hps_parametric_study.For parameters the attributes will return a list of
str,int,floatorboolvalues. An output parameter value will beNoneif a given design point has not successfully evaluated. A file value will beNoneif the file does not exist in HPS.For example if the project has a parameter named
temperaturethen the instance will have an attribute namedtemperaturewhich will return a list of values of the parameter across the design points in the project.- fetch_values_of_parameter(parameter_name: str, design_points: HpsDesignPointSelection | None = None) list[Any]#
A method that returns the values of a given named parameter or the references to instances of a given named file across a set of design points. If you wish to fetch more than one parameter or file use the
fetch_values_of_parametersmethod.- Parameters:
- parameter_name: str
The parameter or file to be fetched. The string
indexcan be used which represents the index of the design point in the input parameter set.- design_points
HpsDesignPointSelection,optional The set of design points for which parameter values or files are to be fetched. The ordering of the list returned by fetch corresponds to the ordering defined by
design_points. Ifdesign_pointsis not set all design points are returned and the ordering corresponds to the ordering used to create the project.
- Returns:
list[Any]The values of a given named parameter or the references to instances of a given named file across the design point ordering specified by
design_points. If a file has been requested then the returned list will containEntityHandleobjects where files exist orNonewhere they do not. If a parameter has been requested then the returned list will containNonevalues for design points which have not successfully evaluated.
- fetch_values_of_parameters(parameter_names: list[str], design_points: HpsDesignPointSelection | None = None) list[list[Any]]#
A method that returns the values of a set of named parameters or files across a set of design points. The files values are returned as
EntityHandleobjects.- Parameters:
- parameter_names: list[str]
The parameters or files that are to be fetched. The string
indexcan be included which represents the index of the design point in the input parameter set.- design_points
HpsDesignPointSelection,optional The set of design points for which parameter values are to be fetched. The ordering of the list returned by fetch corresponds to the ordering defined by design_points. If design_points is not set all design points are returned and the ordering corresponds to the ordering used to create the project.
- Returns:
list[Any]A list of lists of values of the requested files or parameters. Each item in the returned list corresponds to parameter or file names at the same index in
parameter_names. Each sublist contains values for the named parameter or file. The order of the sublists corresponds to the design point ordering specified bydesign_points. Where the sublist corresponds to a file the sublist will containEntityHandleobjects where files exist orNonewhere they do not. Where the sublist corresponds to a parameter the sublist will containNonevalues for design points which have not successfully evaluated.
- static get_compute_resource_sets(hps_server_url: str | None = None, client_id: str | None = None) list[HpsComputeResourceSet]#
Get available compute resource sets in HPS.
- Parameters:
- hps_server_url: str, optional
HPS endpoint that the HPS client will connect to.
- client_id: str, optional
Client ID of the HPS system in Keycloak.
- Returns:
list[HpsComputeResourceSet]A list of objects that represent the available resources to execute an HPS job.
- get_status_of_design_points(design_points: HpsDesignPointSelection | None = None) list[IHpsJobStatus]#
Get the status of the design points in the study. The order of the returned value is the order of the design points supplied to
HpsParametricStudyDefinition.add_study_to_project.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod start_hps_parametric_study(common_input_files: dict[str, HpsInputFileSpecification | Path | EntityHandle | HpsInputDirectorySpecification], input_parameter_values: Iterator[Mapping[str, Any]] | Mapping[str, Sequence[Any]], output_parameters: Mapping[str, type | HpsOutputFileSpecification | HpsOutputDirectorySpecification], max_execution_time: float = 604800, name: str | None = None, resource_requirements: ResourceRequirements | None = None, dependencies: list[str] | None = None, use_product_environment: bool | None = None, python_version: str | None = None, product_environment_version: str | None = None, products: list[Software] | None = None, use_ansys_python: bool = False, hps_server_url: str | None = None, client_id: str | None = None, use_latest_python: bool = False) HpsParametricStudyProject#
- This method creates a new HPS project containing a parametric study and returns
a
HpsParametricStudyProjectobject referring to the project.
See the corresponding section for examples of calling this method.
To understand how the method supports the use of PyAnsys packages see the corresponding section on the SAF product environment. The parametric study API is identical to the job API in this aspect: ‘job’ is equivalent to ‘design point evaluation’ and
start_hps_job()is equivalent tostart_hps_parametric_study.- Parameters:
- common_input_files
- dict[str, HpsInputFileSpecification | HpsInputDirectorySpecification | Path]
This dictionary contains references to files that are common to all design points. Use the
HpsInputFileSpecificationandHpsInputDirectorySpecificationclasses to define the file or directory with an explicit path within the current working directory of a design point evaluation running in HPS. ForPathandEntityHandlevalues the file is copied to the current working directory of a design point evaluation running in HPS and has the same file name as the source.This dictionary must contain an entry with key
scriptwhich specifies an input file which is a python module that is run to evaluate a design point. See the corresponding section (GLOW HPS Scripts) to understand the form of those scripts. The parametric study API is identical to the job API in this aspect: ‘job’ is equivalent to ‘design point evaluation’ andstart_hps_job()is equivalent tostart_hps_parametric_study.input_parameter_values : Iterator[dict[str,Any]]|dict[str,list[Any]]
This argument defines the initial input design point data of the study. The argument is either an iterator that returns a stream of dictionaries of input values or a dictionary of lists of values. The keys to the dictionaries are arbitrary input parameter names. In the case of iterator each iteration defines a design point and the keys should be the same on every iteration. In the other case (a simple dictionary) the dictionary’s values are lists where the lists should have the same lengths. The set of list items with the same index defines a design point.
output_parameters : dict[str, type | HpsOutputFileSpecification | HpsOutputDirectorySpecification]
This argument specifies the required output parameters, files and directories. Each item represents either an output parameter, an output file or an output directory. The key is the name of the parameter, file or directory in HPS.
HpsOutputFileSpecificationvalues are used to represent output files andHpsOutputDirectorySpecificationvalues are used to represent output directories, (HPS parameters are not created for them). Pythontypevalues are used to represent HPS output parameters.- max_execution_time: float, optional
The maximum execution time of each job in seconds. The default is one week.
- resource_requirements: ResourceRequirements, optional
The resource requirements of each job. Uses HPS default values when values are not provided.
- dependencies: list[str], optional
A list of pip requirement specifier strings indicating the python packages that are required to evaluate a design point. Use of this parameter will trigger the creation of a Python virtual environment for each design point and the design point evaluation will not use the SAF Product Environment virtual environment. Use the
python_versionparameter to specify the version of Python for the virtual environment. Thedependenciesargument does not determine what products and applications are available for design point evaluation, use theproductsargument for that purpose. See the corresponding section for details on specifying python package dependencies for jobs (the parametric study API is identical to the job API in this aspect: ‘job’ is equivalent to ‘design point evaluation’)- use_product_environment: bool, optional
Whether to use the SAF Product Environment virtual environment for design point evaluation. By default, the SAF Product Environment virtual environment is used if the
dependenciesargument is not set or is empty. By default, the SAF Product Environment virtual environment is not used if thedependenciesargument is set to a non-empty list.- python_version: str, optional
The version of Python to use for design point evaluation when the SAF Product environment is not used. The string is of the form “major.minor” where major and minor are integers. The default value is “3.11”.
- product_environment_version: str, optional
The version of the SAF Product Environment to use for design point evaluation. The format of the version string of a SAF Product Environment has not yet been determined.
- products: list[Software], optional
A list of products or applications required for design point evaluation. The list items must be of type
Software. The default value is an empty list. The list should not contain entries for python or the SAF Product Environment. See the corresponding section for details on specifying product requirements for jobs (the parametric study API is identical to the job API in this aspect: ‘job’ is equivalent to ‘design point evaluation’).- use_ansys_python: bool, optional
Whether to use Ansys Python instead of Python for the job when the SAF Product environment is not used. The selected Ansys Python version is determined by python_version. The default value is False.
- hps_server_url: str, optional
HPS endpoint that the HPS client will connect to.
- client_id: str, optional
Client ID of the HPS system in the OAuth system.
- Returns:
HpsParametricStudyProjectA serializable reference to the created project.
- class ansys.saf.glow.solution.hps.HpsParametricStudyProjectBase(*, hps_project_identifier: str = '', hps_server_url: str | None = None, client_id: str | None = None, file_parameters_using_handles: list[str] = [], pickled_parameters: list[str] = [])#
Bases:
HpsProjectA reference to a parametric study project in HPS.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ansys.saf.glow.solution.hps.HpsProject(*, hps_project_identifier: str = '', hps_server_url: str | None = None, client_id: str | None = None, file_parameters_using_handles: list[str] = [], pickled_parameters: list[str] = [])#
Bases:
BaseModelA reference to a project in HPS.
- property finished: bool#
Whether all the jobs in the project are evaluated, failed, timed-out or aborted, that is no job is pending or running.
- static get_compute_resource_sets(hps_server_url: str | None = None, client_id: str | None = None) list[HpsComputeResourceSet]#
Get available compute resource sets in HPS.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- exception ansys.saf.glow.solution.hps.HpsProjectNotStartedError#
Bases:
ExceptionAn exception raised when a HPS project is accessed before being started.
- class ansys.saf.glow.solution.hps.HpsQueue(*, name: str)#
Bases:
BaseModelA queue of an HPS compute resource set.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ansys.saf.glow.solution.hps.HpsSimpleProject(*, hps_project_identifier: str = '', hps_server_url: str | None = None, client_id: str | None = None, file_parameters_using_handles: list[str] = [], pickled_parameters: list[str] = [])#
Bases:
HpsSimpleProjectBaseA reference to a HPS project containing one job.
Notes
When instances of this class reference an HPS project they have attributes for the parameters and files of the job contained in the project. The names of these attributes are those used for these entities in HPS and passed to
start_hps_job. For example if the job has a parameter namedtemperaturethen the instance will have an attribute namedtemperaturewhich will return the value of the parameter.- static get_compute_resource_sets(hps_server_url: str | None = None, client_id: str | None = None) list[HpsComputeResourceSet]#
Get available compute resource sets in HPS.
- Parameters:
- hps_server_url: str, optional
HPS endpoint that the HPS client will connect to.
- client_id: str, optional
Client ID of the HPS system in Keycloak.
- Returns:
list[HpsComputeResourceSet]A list of objects that represent the available resources to execute an HPS job.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod start_hps_job(input_values: dict[str, Any], output_parameters: Mapping[str, type | HpsOutputFileSpecification | HpsOutputDirectorySpecification], max_execution_time: float = 604800, name: str | None = None, resource_requirements: ResourceRequirements | None = None, dependencies: list[str] | None = None, use_product_environment: bool | None = None, python_version: str | None = None, product_environment_version: str | None = None, products: list[Software] | None = None, use_ansys_python: bool = False, hps_server_url: str | None = None, client_id: str | None = None, use_latest_python: bool = False) HpsSimpleProject#
This method creates a new HPS project containing a job and returns a
HpsSimpleProjectobject referring to that project.See the corresponding section for examples and further documentation of this method.
To understand how the method supports the use of PyAnsys packages see the corresponding section on the SAF product environment.
- Parameters:
- input_values
dict[str,Any] This argument defines the initial input data of the job. Each key is the name of the parameter or file in HPS.
For each
HpsInputFileSpecification,PathorEntityHandlevalue a HPS file will be created. ForHpsInputDirectorySpecificationvalues a directory in HPS will be created. For all other types a HPS parameter will be created.Use the
HpsInputFileSpecificationclass to define the file with an explicit path within the current working directory of a design point evaluation running in HPS. ForPathandEntityHandlevalues the file is copied to the current working directory of a design point evaluation running in HPS and has the same file name as the source.This dictionary must contain an entry with key
scriptwhich specifies an input file which is a python module that is run to evaluate a design point. See the corresponding section (GLOW HPS Scripts) to understand the form of those scripts.- output_parameters
dict[str,type|HpsOutputFileSpecification|HpsOutputDirectorySpecification] This argument specifies the required output parameters and files. Each item represents either an output parameter or an output file. Each key is the name of the parameter or file in HPS.
HpsOutputFileSpecificationvalues are used to represent output files (HPS parameters are not created for them).HpsOutputDirectorySpecificationvalues are used to represent output directories. Pythontypevalues are used to represent HPS output parameters.- max_execution_time: float, optional
The maximum execution time of the job in seconds. The default is one week.
- resource_requirements: ResourceRequirements, optional
The resource requirements the job. Uses HPS default values when values are not provided.
- dependencies: list[str], optional
A list of pip requirement specifier strings indicating the python packages that are required to evaluate a design point. Use of this parameter will trigger the creation of a Python virtual environment for the job. The job will not use the SAF Product Environment virtual environment. Use the
python_versionparameter to specify the version of Python for the virtual environment. Thedependenciesargument does not determine what products and applications are available for design point evaluation, use theproductsargument for that purpose. See the corresponding section for details on specifying python package dependencies for jobs.- use_product_environment: bool, optional
Whether to use the SAF Product Environment virtual environment for the job. By default, the SAF Product Environment virtual environment is used if the
dependenciesargument is not set or is empty. By default, the SAF Product Environment virtual environment is not used if thedependenciesargument is set to a non-empty list.- python_version: str, optional
The version of Python to use for the job when the SAF Product environment is not used. The string is of the form “major.minor” where major and minor are integers. The default value is “3.11”.
- product_environment_version: str, optional
The version of the SAF Product Environment to use for the job. The format of the version string of a SAF Product Environment has not yet been determined.
- products: list[Software], optional
A list of products or applications required for the job. The list items must be of type
Software. The default value is an empty list. The list should not contain entries for python or the SAF Product Environment. See the corresponding section for details on specifying product requirements for jobs.- use_ansys_python: bool, optional
Whether to use Ansys Python instead of Python for the job when the SAF Product environment is not used. The selected Ansys Python version is determined by python_version. The default value is False.
- hps_server_url: str, optional
HPS endpoint that the HPS client will connect to.
- client_id: str, optional
Client ID of the HPS system in Keycloak.
- input_values
- Returns:
HpsSimpleProjectA reference to a HPS project that can be stored in a GLOW step field.
- property status: IHpsJobStatus#
Get the status of the job in the project.
- class ansys.saf.glow.solution.hps.HpsSimpleProjectBase(*, hps_project_identifier: str = '', hps_server_url: str | None = None, client_id: str | None = None, file_parameters_using_handles: list[str] = [], pickled_parameters: list[str] = [])#
Bases:
HpsProjectA reference to a single job project in HPS.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ansys.saf.glow.solution.hps.IHpsJobStatus(*args, **kwargs)#
Bases:
ProtocolThe status of a HPS job.
- property evaluation_status: HpsJobEvaluationStatus#
The evaluation state of the job.
- class ansys.saf.glow.solution.hps.ResourceRequirements(platform: str = <marshmallow.missing>, memory: int = <marshmallow.missing>, num_cores: float = <marshmallow.missing>, disk_space: int = <marshmallow.missing>, distributed: bool = <marshmallow.missing>, compute_resource_set_id: str = <marshmallow.missing>, evaluator_id: str = <marshmallow.missing>, custom: dict[str, int | float | str | bool]=<marshmallow.missing>, hpc_resources: HpcResources = <marshmallow.missing>, **kwargs)#
Bases:
ObjectProvides the resource requirements resource.
- Parameters:
- platform
str,optional Basic platform information. Options are
'linux'and'windows'.- memory
int,optional Amount of RAM in bytes.
- num_cores
float,optional Number of cores.
- disk_space
int,optional Amount of disk space in bytes.
- distributedbool,
optional Whether to enable distributed parallel processing.
- compute_resource_set_id
str,optional ID of the compute resource set that this task should run on.
- evaluator_id
str,optional ID of the evaluator that this task should run on.
- custom
dict[str,Union[int,float,str, bool]],optional Dictionary of custom resource requirements.
- hpc_resources
HpcResources,optional HPC resource requirements.
- platform
- class ansys.saf.glow.hps_execution.HpsExecution#
Bases:
ABCA job or design point evaluation for execution in HPS. Derived classes implement the computation comprising the job or design point evaluation.
- property context: HpsExecutionContext#
The context of an execution of the job or design point evaluation providing information about the job or design point evaluation.
- abstractmethod execute() Dict[str, Any]#
The core execution of the job or design point evaluation. This method must be implemented by the derived class.
This method should:
extract input parameter values from the
input_parametersproperty of thecontextproperty.read input files from the current working directory. Reading files can be guided by the values (for those entries matching input files) in the
input_parametersproperty of thecontextproperty which are the absolute paths to the input files for the job.write output files to the current working directory (can be guided by the
required_output_filesproperty of thecontextproperty)throw exceptions when error conditions are encountered
output logs to std out
This method can access information about the products or applications required by the job via the
productsproperty of thecontextproperty.If the evaluation needs to start a subprocess it is recommended that the
run_and_capture_output()method is used.- Returns:
Dict[str,Any]]A dictionary of output parameter values where the keys and types of the values match the definition passed to the
output_parametersargument of thestart_hps_parametric_study()orstart_hps_job()method call that created the job or design point.
- load_impl(impl: HpsExecutionFunctionality)#
Do not call this method from Solution code.
- run_and_capture_output(args: List[Any], keyword_args: dict[str, Any])#
Convenience function to execute an application in a new process, log its stdout/stderr and wait until the process completes.
- Parameters:
- args
See args in subprocess.Popen
- **kwargs
Allows you to pass keyword arguments to subprocess.Popen, except for stdout and stderr which are overridden as
stdout = subprocess.PIPE
stderr = subprocess.STDOUT
- class ansys.saf.glow.hps_execution.HpsExecutionContext#
Bases:
ABCThe context of an execution of a HPS job or design point evaluation providing information about the job or design point evaluation.
- abstract property input_parameters: Dict[str, Any]#
The input parameters and files of the job or design point evaluation. The keys are the names of the parameters or files. For parameters the values in the dictionary are the values of the parameters. For files the values in the dictionary are the absolute paths to the file.
- abstract property products: List[HpsProduct]#
The products that were required for the job or design point evaluation includes the products passed to the project creation method.
- property required_output_directories: Dict[str, str]#
A dictionary where the keys are the key names of the output directories that the project definition expects from the job or design point evaluation. The values of the dictionary are the relative paths where the directories are expected.
- class ansys.saf.glow.hps_execution.HpsExecutionFunctionality#
Bases:
ABCThe internal implementation of functionality to support execution of a HPS job or design point.