Skip to content

Commit

Permalink
Use json.loads in OutputClientScriptJob
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein authored and replaceafill committed May 22, 2024
1 parent 322b8b3 commit 4ecae45
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/MCPServer/lib/server/jobs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import abc
import ast
import json
import logging

from dbconns import auto_close_old_connections
Expand Down Expand Up @@ -235,13 +236,14 @@ def submit_tasks(self):


class OutputClientScriptJob(ClientScriptJob):
"""Retrieves output (e.g. a set of choices) from mcp client, for use in a decision.
"""Retrieves output (e.g. a set of choices) from MCPClient, for use in a decision.
Output is returned via stderr, and parsed via eval. It is stored for access by the
next job on the `generated_choices` attribute of the job chain, which is used for
only this purpose.
TODO: Remove from workflow if possible.
TODO: Remove from workflow if possible - this is only used by
getAipStorageLocations_v0.0 (twice).
"""

# We always need output for this type of job
Expand All @@ -251,8 +253,8 @@ def task_completed_callback(self, task):
logger.debug("stdout emitted by client: %s", task.stdout)

try:
choices = ast.literal_eval(task.stdout)
except (ValueError, SyntaxError):
choices = json.loads(task.stdout)
except (TypeError, ValueError):
logger.exception("Unable to parse output %s", task.stdout)
choices = {}

Expand Down

0 comments on commit 4ecae45

Please sign in to comment.