JobManagerHandler#
- class pyedb.workflows.job_manager.backend.job_manager_handler.JobManagerHandler(edb=None, version=None, host='localhost', port=8080)#
Synchronous façade that controls an async Job Manager service.
This class provides a thread-safe interface to manage asynchronous job execution while running the aiohttp server in a background thread.
- Parameters:
- Raises:
ValueErrorIf specified ANSYS version is not found
RuntimeErrorIf service fails to start within timeout
Examples
>>> handler = JobManagerHandler() >>> handler.start_service() >>> print(f"Server running at {handler.url}") >>> # Submit jobs via REST API or handler methods >>> handler.close()
Overview#
Synchronously submit a simulation job. |
|
Block until the requested job reaches a terminal state |
|
Block until every job currently known to the manager |
|
Get system status and scheduler information. |
|
Get current user information. |
|
Get list of all jobs with their current status. |
|
Get detected scheduler type. |
|
Get available cluster partitions/queues. |
|
Get parsed HFSS log for a finished job. |
|
Submit a new simulation job. |
|
Get current queue status for UI display. |
|
Get current resource usage for UI display. |
|
Cancel a running or queued job. |
|
Start the job manager service in a background thread. |
|
Gracefully shutdown the job manager service. |
|
Stop the aiohttp server and cleanup resources. |
|
Create a validated HFSSSimulationConfig. |
Get the server URL. |
Import detail#
from pyedb.workflows.job_manager.backend.job_manager_handler import JobManagerHandler
Property detail#
- property JobManagerHandler.url: str#
Get the server URL.
- Returns:
strFull server URL (http://host:port)
Attribute detail#
- JobManagerHandler.scheduler_type#
- JobManagerHandler.manager#
- JobManagerHandler.sio#
- JobManagerHandler.app#
- JobManagerHandler.site = None#
- JobManagerHandler.started = False#
- JobManagerHandler.resource_limits = None#
Method detail#
- JobManagerHandler.submit_job(config: pyedb.workflows.job_manager.backend.job_submission.HFSSSimulationConfig, priority: int = 0, timeout: float = 30.0) str#
Synchronously submit a simulation job.
The method is thread-safe: it marshals the async work into the background event-loop and returns the job identifier.
- Parameters:
- Returns:
strUnique job identifier (same as
config.jobid).
- Raises:
RuntimeErrorIf the service is not started or the submission times out.
ExceptionAny validation / scheduler error raised by the underlying coroutine.
Examples
>>> from pyedb.workflows.job_manager.backend.job_manager_handler import JobManagerHandler >>> from pyedb.workflows.job_manager.backend.job_submission import create_hfss_config, SchedulerType
>>> handler = JobManagerHandler() >>> handler.start_service() >>> cfg = create_hfss_config( >>> ansys_edt_path=..., >>> jobid="my_job", >>> project_path=..., >>> scheduler_type=SchedulerType.NONE >>> ) >>> job_id = handler.submit_job(cfg, priority=0) >>> print("submitted", job_id) >>> # later >>> handler.close()
- JobManagerHandler.wait_until_done(job_id: str, poll_every: float = 2.0) str#
Block until the requested job reaches a terminal state (completed, failed, or cancelled).
- Returns:
strTerminal status string.
- JobManagerHandler.wait_until_all_done(poll_every: float = 2.0) None#
Block until every job currently known to the manager is in a terminal state.
- async JobManagerHandler.get_system_status(request)#
Get system status and scheduler information.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON response with system status
- async JobManagerHandler.get_me(request)#
Get current user information.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON response with username
- async JobManagerHandler.get_jobs(request)#
Get list of all jobs with their current status.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON array of job objects
- async JobManagerHandler.get_scheduler_type(request)#
Get detected scheduler type.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON response with scheduler type
- async JobManagerHandler.get_cluster_partitions(request)#
Get available cluster partitions/queues.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON array of partition information
- async JobManagerHandler.get_job_log(request)#
Get parsed HFSS log for a finished job.
- Parameters:
- request
aiohttp.web.Request HTTP request with job_id in URL path
- request
- Returns:
aiohttp.web.Response200: JSON with parsed log data
204: No log available yet
404: Job not found
500: Log parsing error
- async JobManagerHandler.handle_submit_job(request)#
Submit a new simulation job.
- Parameters:
- request
aiohttp.web.Request HTTP request with JSON payload containing job configuration
- request
- Returns:
aiohttp.web.ResponseJSON response with job ID and status
Notes
Expected JSON payload:
{ "config": { "scheduler_type": "slurm|lsf|none", "project_path": "/path/to/project.aedt", ... other HFSS config fields }, "user": "username", "machine_nodes": [...], "batch_options": {...} }
- async JobManagerHandler.get_queue_status(request)#
Get current queue status for UI display.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON with queue statistics
- async JobManagerHandler.get_resources(request)#
Get current resource usage for UI display.
- Parameters:
- request
aiohttp.web.Request HTTP request object
- request
- Returns:
aiohttp.web.ResponseJSON with current resource usage
- async JobManagerHandler.cancel_job(request)#
Cancel a running or queued job.
- Parameters:
- request
aiohttp.web.Request HTTP request with job_id in URL path
- request
- Returns:
aiohttp.web.ResponseJSON response with cancellation status
- JobManagerHandler.start_service() None#
Start the job manager service in a background thread.
- Raises:
RuntimeErrorIf service fails to start within 10 seconds
Notes
This method is non-blocking and returns immediately. The service runs in a daemon thread with its own event loop.
- JobManagerHandler.close() None#
Gracefully shutdown the job manager service.
Notes
This method is automatically called on program exit via atexit, but can also be called explicitly for clean shutdown.
- async JobManagerHandler.stop_service() None#
Stop the aiohttp server and cleanup resources.
This is the async version of close() that runs in the event loop.
- JobManagerHandler.create_simulation_config(project_path: str, ansys_edt_path: str | None = None, jobid: str | None = None, scheduler_type: pyedb.workflows.job_manager.backend.job_submission.SchedulerType | None = None, cpu_cores: int = 1, user: str = 'unknown') pyedb.workflows.job_manager.backend.job_submission.HFSSSimulationConfig#
Create a validated HFSSSimulationConfig.
- Parameters:
- project_path
str Path to the AEDT project file
- ansys_edt_path
str,optional Path to ANSYS EDT executable. Uses detected path if None.
- jobid
str,optional Job identifier. Auto-generated if None.
- scheduler_type
SchedulerType,optional Scheduler type. Uses detected scheduler if None.
- cpu_cores
int Number of CPU cores for local execution
- user
str Username for job ownership
- project_path
- Returns:
HFSSSimulationConfigValidated simulation configuration
- Raises:
ValueErrorIf project_path is empty or invalid
Notes
The cpu_cores parameter is only used when scheduler_type is NONE (local execution). For cluster execution, cores are determined by the scheduler configuration.