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: BaseModel

A 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: object

A selector of design points in a HpsParametricStudyProject. The required_design_points, eval_status and parameter_filter arguments, when present, combine to define a base set of design points. This base set can then be sorted via the sort argument. The base set is then further restricted by the limit and offset arguments.

Parameters:
required_design_pointslist[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_statusHpsJobEvaluationStatus | 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.

limitint | 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.

offsetint | 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.

sortstr | 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_filterdict[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 to

  • ne - not equal to

  • lt - less than

  • le - less than or equal to

  • gt - greater than

  • ge - greater than or equal to

  • in - in a list of values

  • contains - 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 value 100 would only include design points where the temperature parameter is greater than 100.

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: object

Specification 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_parametersdict[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. HpsOutputFileSpecification values are used to represent output files and HpsOutputDirectorySpecification values are used to represent output directories, (HPS parameters are not created for them). Python type values 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 the scripts directory located in the directory containing the step definition module that contains the transaction method that calls execute. If module is a Path object 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/simulation is transferred to HPS then you can pass Path("ansys/solutions/fastcar/simulation") as the module argument.

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_version parameter to specify the version of Python for the virtual environment. The dependencies argument does not determine what products and applications are available for design point evaluation, use the products argument 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 dependencies argument is not set or is empty. By default, the SAF Product Environment virtual environment is not used if the dependencies argument 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:
**kwargsAny

The arguments to pass to the function. Arguments of the types Path, EntityHandle`, HpsInputFileSpecification and HpsInputDirectorySpecification are treated as input files or directories. The referenced files and directories are transferred to HPS for job execution. Path values 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.

execute_parametric_study(**kwargs: Any) → HpsParametricStudyProject#

Execute a parametric study with the specified function and arguments.

Parameters:
**kwargsAny

The arguments to pass to the function. Arguments of the types Path EntityHandle`, HpsInputFileSpecification and HpsInputDirectorySpecification are treated as input files or directories. The referenced files and directories are transferred to HPS for job execution. Path values 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.

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:
sourceEntityHandle | Path

The source of the directory.

evaluation_pathstr | 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 None value) is to copy the directory into the current working directory with same filename as the source directory

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:
sourcePath

The source of the file.

evaluation_pathstr | 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 None value) is to copy the file into the current working directory with same filename as the source file

class ansys.saf.glow.solution.hps.HpsJobEvaluationStatus(*values)#

Bases: Enum

The 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: Exception

An 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: HpsOutputSourceSpecification

The specification of a directory which will be generated by a HPS job.

Parameters:
evaluation_pathstr | 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 None value) 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 the HpsOutputDirectorySpecification object in the dictionary passed as an output_parameters argument to start_hps_job() or start_hps_parametric_study().

monitorbool, optional

This flag determines whether the directory is monitored for changes by HPS. The default is False.

collect_intervalint, optional

Collection frequency for the directory, specified in seconds. The default is 0.

class ansys.saf.glow.solution.hps.HpsOutputFileSpecification(evaluation_path: str | None = None, monitor: bool = False, collect_interval: int = 0)#

Bases: HpsOutputSourceSpecification

The specification of a file which will be generated by a HPS job.

Parameters:
evaluation_pathstr | 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 None value) 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 the HpsOutputFileSpecification object in the dictionary passed as an output_parameters argument to start_hps_job() or start_hps_parametric_study().

monitorbool, optional

This flag determines whether the file is monitored for changes by HPS. The default is False.

collect_intervalint, optional

Collection frequency for the file, specified in seconds. The default is 0.

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: HpsParametricStudyProjectBase

A 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 to start_hps_parametric_study.

For parameters the attributes will return a list of str, int, float or bool values. An output parameter value will be None if a given design point has not successfully evaluated. A file value will be None if the file does not exist in HPS.

For example if the project has a parameter named temperature then the instance will have an attribute named temperature which 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_parameters method.

Parameters:
parameter_name: str

The parameter or file to be fetched. The string index can be used which represents the index of the design point in the input parameter set.

design_pointsHpsDesignPointSelection, 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. 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]

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 contain EntityHandle objects where files exist or None where they do not. If a parameter has been requested then the returned list will contain None values 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 EntityHandle objects.

Parameters:
parameter_names: list[str]

The parameters or files that are to be fetched. The string index can be included which represents the index of the design point in the input parameter set.

design_pointsHpsDesignPointSelection, 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 by design_points. Where the sublist corresponds to a file the sublist will contain EntityHandle objects where files exist or None where they do not. Where the sublist corresponds to a parameter the sublist will contain None values 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 HpsParametricStudyProject object 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 to start_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 HpsInputFileSpecification and HpsInputDirectorySpecification classes to define the file or directory with an explicit path within the current working directory of a design point evaluation running in HPS. For Path and EntityHandle values 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 script which 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’ and start_hps_job() is equivalent to start_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. HpsOutputFileSpecification values are used to represent output files and HpsOutputDirectorySpecification values are used to represent output directories, (HPS parameters are not created for them). Python type values 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_version parameter to specify the version of Python for the virtual environment. The dependencies argument does not determine what products and applications are available for design point evaluation, use the products argument 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 dependencies argument is not set or is empty. By default, the SAF Product Environment virtual environment is not used if the dependencies argument 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:
HpsParametricStudyProject

A 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: HpsProject

A 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: BaseModel

A reference to a project in HPS.

property exists: bool#

Whether the project exists 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].

property ui_url: str#

The URL of the project in the HPS UI.

exception ansys.saf.glow.solution.hps.HpsProjectNotStartedError#

Bases: Exception

An exception raised when a HPS project is accessed before being started.

class ansys.saf.glow.solution.hps.HpsQueue(*, name: str)#

Bases: BaseModel

A 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: HpsSimpleProjectBase

A 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 named temperature then the instance will have an attribute named temperature which 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 HpsSimpleProject object 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_valuesdict[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, Path or EntityHandle value a HPS file will be created. For HpsInputDirectorySpecification values a directory in HPS will be created. For all other types a HPS parameter will be created.

Use the HpsInputFileSpecification class to define the file with an explicit path within the current working directory of a design point evaluation running in HPS. For Path and EntityHandle values 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 script which 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_parametersdict[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. HpsOutputFileSpecification values are used to represent output files (HPS parameters are not created for them). HpsOutputDirectorySpecification values are used to represent output directories. Python type values 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_version parameter to specify the version of Python for the virtual environment. The dependencies argument does not determine what products and applications are available for design point evaluation, use the products argument 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 dependencies argument is not set or is empty. By default, the SAF Product Environment virtual environment is not used if the dependencies argument 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.

Returns:
HpsSimpleProject

A 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: HpsProject

A 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: Protocol

The 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: Object

Provides the resource requirements resource.

Parameters:
platformstr, optional

Basic platform information. Options are 'linux' and 'windows'.

memoryint, optional

Amount of RAM in bytes.

num_coresfloat, optional

Number of cores.

disk_spaceint, optional

Amount of disk space in bytes.

distributedbool, optional

Whether to enable distributed parallel processing.

compute_resource_set_idstr, optional

ID of the compute resource set that this task should run on.

evaluator_idstr, optional

ID of the evaluator that this task should run on.

customdict[str, Union[int, float, str, bool]], optional

Dictionary of custom resource requirements.

hpc_resourcesHpcResources, optional

HPC resource requirements.

class Meta#

Bases: object

schema#

alias of ResourceRequirementsSchema

class ansys.saf.glow.hps_execution.HpsExecution#

Bases: ABC

A 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_parameters property of the context property.

  • 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_parameters property of the context property 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_files property of the context property)

  • 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 products property of the context property.

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_parameters argument of the start_hps_parametric_study() or start_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: ABC

The 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.

abstract property required_output_files: Dict[str, str]#

A dictionary where the keys are the key names of the output files that the project definition expects from the job or design point evaluation. The values of the dictionary are the relative paths where the files are expected.

abstract property required_output_parameters: List[str]#

The key names of the output parameters passed to the project creation method.

class ansys.saf.glow.hps_execution.HpsExecutionFunctionality#

Bases: ABC

The internal implementation of functionality to support execution of a HPS job or design point.

class ansys.saf.glow.hps_execution.HpsProduct#

Bases: ABC

A product accessible to a HPS job or design point evaluation.

abstract property executable: Path#

The path to the executable of the product.

abstract property name: str#

HPS name of the product.

abstract property version: str#

Version of the product (Ansys products use the form ‘<year> R<release>’).