SLRUM for PyMechanical.?

Naveen Kumar Begari
Naveen Kumar Begari Member Posts: 77
10 Comments 5 Likes First Answer First Anniversary
**

Hello @James Derrick

I’m reaching out to seek your advice on the best strategy for submitting jobs from PyAnsys (on a Windows machine) to a SLURM cluster. Currently, our process involves copying the .py file and running it through SLURM. I was wondering if there’s a more streamlined approach, similar to how we use ANSYS RSM for Workbench submissions.

Looking forward to your insights!

Comments

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 347
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 77
    10 Comments 5 Likes First Answer First Anniversary
    **

    @Landon Mitchell Kanner whether the HPS works between windows to Linux.?

  • Andreas Rydin
    Andreas Rydin Member, Employee Posts: 4
    Second Anniversary Name Dropper First Comment Ansys Employee
    ✭✭✭
    edited February 3

    @Naveen Kumar Begari HPS is able to connect windows clients to a linux based cluster. There are primarily two worksflows that can be used with pyAnsys:
    1. Inside of (py)Mechanical - add a Solve Process Setting corresponding to HPS server and authentication (this is similar to RSM setup)
    2. Use (py)Mechanical to write an input file that is submitted to the cluster using pyHPS
    - Examples available https://hps.docs.pyansys.com/

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 77
    10 Comments 5 Likes First Answer First Anniversary
    **

    @Andreas Rydin Thanks for your information

  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 77
    10 Comments 5 Likes First Answer First Anniversary
    **

    @Andreas Rydin said:
    @Naveen Kumar Begari HPS is able to connect windows clients to a linux based cluster. There are primarily two worksflows that can be used with pyAnsys:
    1. Inside of (py)Mechanical - add a Solve Process Setting corresponding to HPS server and authentication (this is similar to RSM setup)
    2. Use (py)Mechanical to write an input file that is submitted to the cluster using pyHPS
    - Examples available https://hps.docs.pyansys.com/

    @Andreas Rydin

    For First work flow i,e:
    1. Inside of (py)Mechanical - add a Solve Process Setting corresponding to HPS server and authentication (this is similar to RSM setup) --- Can you please share me the examples or workflow setup.?

  • Andreas Rydin
    Andreas Rydin Member, Employee Posts: 4
    Second Anniversary Name Dropper First Comment Ansys Employee
    ✭✭✭
    edited February 6

    @Naveen Kumar Begari Here is a short script to add a HPS queue in solve process settings:

    You can replace the url server with the appropriate HPS server.

    import os, webbrowser
    
    new_hps_config = 'hps_mech'
    n_cores = 20
    url = 'https://<server>:8443/hps'
    
    configs = ExtAPI.Application.SolveConfigurations
    hps_config = [i.Name for i in configs if i.Settings.SolutionExecutionTarget == 'HPC Platform Services']
    
    if hps_config: # exists
        print('HPS configuration found')
        config_name = hps_config[0]
        print(config_name)
        config = ExtAPI.Application.SolveConfigurations[config_name]
        ExtAPI.Log.WriteMessage('Solver now changed to ' + config_name)
        webbrowser.open(url)
        Model.Analyses[0].Solve( True , config_name)
    if not hps_config: # doesn't exist
        print('No HPS configuration found')
        config = Ansys.ACT.Mechanical.Application.SolveProcessSettings.SolveConfiguration()
        config.Settings.License = 'Ansys Mechanical Enterprise'
        config.SolveProcessSettings.MaxNumberOfCores = n_cores
        config.SolveProcessSettings.LicenseQueuing = True
        config.Settings.SolutionExecutionTarget = 'HPC Platform Services'
        config.Settings.DCSUrl = url
        config.Name = new_hps_config
        config.Settings.DCSUsername = os.getenv('username')
        configs.Add(config)
        emsg = HPSConfiguration + ' has been added to your Solver Configurations. Please authenticate and validate. Next time you press this button, you will run your analysis with that configuration.'
        msg = Ansys.Mechanical.Application.Message(emsg, MessageSeverityType.Warning)
        ExtAPI.Application.Messages.Add(msg)
    
  • Naveen Kumar Begari
    Naveen Kumar Begari Member Posts: 77
    10 Comments 5 Likes First Answer First Anniversary
    **

    @Andreas Rydin Thank you for sharing the script. Will get back if any