Skip to content

Commit 7500d23

Browse files
committed
MPM Job handler
1 parent faee45f commit 7500d23

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

Diff for: dapi/components/jobs/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ def __init__(self, api):
1616

1717
def _register_default_handlers(self) -> None:
1818
"""Register default job handlers."""
19-
from .opensees_job_handler import OpenSeesJobHandler # Import default handlers
19+
# Import default handlers
20+
from .opensees_job_handler import OpenSeesJobHandler
21+
from .mpm_job_handler import MpmJobHandler
2022

2123
self.register_handler("opensees", OpenSeesJobHandler)
24+
self.register_handler("mpm", MpmJobHandler)
2225

2326
def register_handler(
2427
self, app_name: str, handler_class: Type[BaseJobHandler]

Diff for: dapi/components/jobs/mpm_job_handler.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from typing import Dict, Any, Optional
2+
from .base_job_handler import BaseJobHandler
3+
4+
5+
class MpmJobHandler(BaseJobHandler):
6+
"""Custom handler for MPM (Material Point Method) jobs."""
7+
8+
def generate_job_info(
9+
self,
10+
tapis_client,
11+
input_uri: str,
12+
input_file: str,
13+
job_name: Optional[str] = None,
14+
max_minutes: Optional[int] = None,
15+
node_count: Optional[int] = None,
16+
cores_per_node: Optional[int] = None,
17+
queue: Optional[str] = None,
18+
allocation: Optional[str] = None,
19+
) -> Dict[str, Any]:
20+
# Get app info for the single MPM app
21+
app_info = tapis_client.apps.getApp(appId="mpm")
22+
23+
# Create the base job info
24+
job_info = {
25+
"name": job_name,
26+
"appId": app_info.id,
27+
"appVersion": app_info.version,
28+
"execSystemId": app_info.jobAttributes.execSystemId,
29+
"maxMinutes": max_minutes or app_info.jobAttributes.maxMinutes,
30+
"archiveOnAppError": app_info.jobAttributes.archiveOnAppError,
31+
"fileInputs": [{"name": "Input Directory", "sourceUrl": input_uri}],
32+
"execSystemLogicalQueue": queue
33+
or app_info.jobAttributes.execSystemLogicalQueue,
34+
"nodeCount": node_count or 1, # Default to 1 if not specified
35+
"coresPerNode": cores_per_node or 1, # Default to 1 if not specified
36+
"parameterSet": {
37+
"appArgs": [{"name": "Input Script", "arg": input_file}],
38+
"schedulerOptions": [],
39+
},
40+
}
41+
42+
# Add TACC allocation if provided
43+
if allocation:
44+
job_info["parameterSet"]["schedulerOptions"].append(
45+
{"name": "TACC Allocation", "arg": f"-A {allocation}"}
46+
)
47+
48+
return job_info

Diff for: dapi/components/jobs/opensees_job_handler.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ def generate_job_info(
2222
additional_params = {
2323
"envVariables": [{"key": "tclScript", "value": input_file}]
2424
}
25-
app_name
25+
26+
# Use default app if no app specified or if specified app doesn't contain 'opensees'
27+
if not app_name or "opensees" not in app_name.lower():
28+
app_name = "opensees-express"
29+
else:
30+
# List available OpenSees apps
31+
apps = tapis_client.apps.getApps(search="opensees")
32+
if not any(app.id == app_name for app in apps):
33+
raise ValueError(
34+
f"App '{app_name}' not found in available OpenSees apps"
35+
)
2636

2737
# Call the generic generate_job_info with OpenSees-specific params
2838
return super().generate_job_info(

0 commit comments

Comments
 (0)