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

Adding assert to static tasks for data type #745

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def update_data(self, live_update: Dict[str, Any]) -> None:
def update_submit(self, submission_data: Dict[str, Any]) -> None:
"""Move the submitted output to the local dict"""
outputs: Dict[str, Any]
assert isinstance(submission_data, dict), (
"Static tasks must get dict results. Ensure you are passing an object to "
f"your frontend task's `handleSubmit` method. Got {submission_data}"
)
output_files = submission_data.get("files")
if output_files is not None:
submission_data["files"] = [f["filename"] for f in submission_data["files"]]
Expand Down
21 changes: 12 additions & 9 deletions mephisto/operations/client_io_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,18 @@ def _on_submit_unit(self, packet: Packet, _channel_id: str):
agent = live_run.worker_pool.get_agent_for_id(packet.subject_id)
assert agent is not None, "Could not find given agent!"

# If the packet is_submit, and has files, we need to
# process downloading those files first
data_files = packet.data.get("files")
if data_files is not None:
save_dir = agent.get_data_dir()
architect = live_run.architect
for f_obj in data_files:
# TODO(#649) this is incredibly blocking!
architect.download_file(f_obj["filename"], save_dir)
# Special handler for file downloads while we have architect access
# NOTE: this is a leaky abstraction at the moment - only architects
# know how to save files but "file saving" methods are defined by
# AgentStates, which don't have architect access.
if isinstance(packet.data, dict):
data_files = packet.data.get("files")
if data_files is not None:
save_dir = agent.get_data_dir()
architect = live_run.architect
for f_obj in data_files:
# TODO(#649) this is incredibly blocking!
architect.download_file(f_obj["filename"], save_dir)

agent.handle_submit(packet.data)

Expand Down