Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to run interrupt command #359

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/mapdl_tyre_performance/exec_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Meta(ApplicationExecution.Meta):

def execute(self):

log.info("Starting MAPDL execution script")
log.info("Starting MAPDL execution script.")

# Identify files
inp_file = next((f for f in self.context.input_files if f["name"] == "inp"), None)
Expand Down Expand Up @@ -71,10 +71,10 @@ def execute(self):
log.info(f"Executing: {cmd}")
subprocess.run(cmd, shell=True, check=True, env=env)

log.info("End MAPDL execution script")
log.info("End MAPDL execution script.")
davel94 marked this conversation as resolved.
Show resolved Hide resolved

def interrupt(self):
log.info("Interrupting MAPDL")
log.info("Interrupting MAPDL.")
with open("file.abt", "w") as file:
file.write("nonlinear")
log.info("Created file.abt")
log.info("Created file.abt.")
8 changes: 4 additions & 4 deletions examples/mapdl_tyre_performance/interrupt_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def interrupt_running_task(client, project_id) -> Project:
{"task_definition_id": task_def.id, "eval_status": "running"}
)
if not running_tasks:
log.info("No running Tasks")
log.info("No tasks are running.")

task = running_tasks[0]
if not task.eval_status == "running":
log.info("Task is not running")
log.info("Task is not running.")
return

project_url = f"{client.url}/jms/api/v1/projects/{project_id}"
Expand All @@ -71,14 +71,14 @@ def interrupt_running_task(client, project_id) -> Project:

resp = client.session.post(command_url, data=data_str)
if not resp.status_code == 201:
log.info("Failed to submit Task command")
log.info("Failed to submit task command.")
return

cmd = resp.json()["task_commands"][0]
while not cmd["status"] == "executed" and not cmd["status"] == "failed":
resp = client.session.get(command_url, params={"id": cmd["id"]})
if not resp.status_code == 200:
log.info("Failed to check Task command status")
log.info("Failed to check task command status.")
cmd = resp.json()["task_commands"][0]
log.info(f"Command status: {cmd['status']}")
time.sleep(0.5)
Expand Down
Loading