Skip to content

fix: call middleware in task creation class - #133

Merged
uniqueg merged 5 commits into
devfrom
fix_#132
Feb 16, 2023
Merged

uniqueg merged 5 commits into
devfrom
fix_#132

Conversation

@Ayush5120

@Ayush5120 Ayush5120 commented Feb 7, 2023 •

Copy link
Copy Markdown
Contributor
  • fix Middleware called before task is created #132 by calling middleware in pro_tes.ga4gh.tes.task_runs.TaskRuns class rather than the upstream pro_tes.ga4gh.tes.server.CreateTask() controller
  • the incoming request is now stored in the database before being modified by any middleware

@Ayush5120 Ayush5120 changed the title fix: Middleware called before task is created fix: middleware called before task is created Feb 7, 2023

@uniqueg uniqueg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread pro_tes/ga4gh/tes/task_runs.py Resolved
Comment thread pro_tes/ga4gh/tes/task_runs.py Resolved

@uniqueg uniqueg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There is one confusing issue. Please have a look and let me know what you think (or open an issue if you agree). Anyway, this doesn't really affect this PR, so I will approve this.

del payload["tes_uri"]

db_document.task_outgoing = TesTask(**payload)
db_document.task_incoming = TesTask(**payload)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm really confused. Didn't we say that we do not want to modify the incoming but only the outgoing request object? At least that is what makes sense. If we modify the incoming request, it's not the incoming request anymore. And the outgoing request is a copy of the incoming request that was modified by the middlware, and with a ranked list of TES endpoints attached. And it is also the outgoing request that should be updated according to what is happening on the remote service and what is, essentially, returned to the user when they ask for info on that task (except a few properties like the start and other times pertaining to the task itself (not for the executor).

This all looks like it is actually done the other way around (or maybe I'm being stupid).

If that is the case, please open an issue to fix in another PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, task_outgoing is the one that is untouched, and all the changes (middleware, the final response etc) are done in task_incoming.

@uniqueg uniqueg Feb 16, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it doesn't make sense. Don't you agree? If we modify the incoming request, it's not the incoming request anymore. Perhaps instead of naming them "incoming" and "outgoing", it might be better to call one of them just task and the other one task_original. Then task is the working copy which gets modified and always keeps all the info just as we want to return it to the user/client.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes makes sense, I am creating an issue for that where we just need to rename it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue #137

@uniqueg uniqueg changed the title fix: middleware called before task is created fix: call middleware during task creation Feb 16, 2023
@uniqueg uniqueg changed the title fix: call middleware during task creation fix: call middleware in task creation class Feb 16, 2023
@uniqueg
uniqueg merged commit ee95471 into dev Feb 16, 2023
@uniqueg
uniqueg deleted the fix_#132 branch February 16, 2023 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Middleware called before task is created

2 participants