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

fix #7153: raydata enable/disable auto processing of scans from the GUI #7199

Merged
merged 18 commits into from
Aug 7, 2024

Conversation

rorour
Copy link
Contributor

@rorour rorour commented Jul 31, 2024

@rorour rorour requested review from moellep and e-carlin July 31, 2024 23:22
Copy link
Member

@moellep moellep left a comment

Choose a reason for hiding this comment

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

This PR will need to wait for pykern pkasyncio-changes PR to be merged.

@e-carlin could you check the logic in scan_monitory.py

@e-carlin
Copy link
Member

e-carlin commented Aug 6, 2024

I tried to leave a review in words. But, I was struggling to get my points across. So, I reviewed by changing the code. Please take a look fcd6b63. We can setup a meeting to discuss if you want

Some general thoughts:

  • Reviewing the code there was something that just seemed a bit too complicated to me. I had to jump back and forth between _AUTOMATIC_ANALYSIS_HANDLER_TASKS and _CHANGE_AUTOMATIC_ANALYSIS to see what was going on. There just seemed to be too much logic for what amounts to one question. Should this task be doing work (analysis) or not?
  • I noticed that this function no longer awaited anything but just created some tasks. So, there was no reason to pass it to run. asyncio has some real foot guns around tasks that no one awaits. I'm still not 100% sure myself how it all works. But, basically I think if you create a task you should await it. If you don't I think exceptions might not be propagated correctly. Again, not 100% sure myself how it all works but having tasks that weren't awaited was odd to me.
  • This function was a bit of a smell. You just pkdel from _CATALOG_MONITOR_TASKS but the task is never explicitly canceled. Maybe the garbage collector cancels it? Not sure. Cancel is really really tricky. Something we wish we had handled differently in the job_supervisor. But going forward my general rule is to avoid cancel in the form of python CanceledError like the plague. Instead, do what you were sort of doing and signal to tasks that they should stop whatever they are doing (and maybe "cancel" themselves by returning). That's what my code does. It uses _WANT_AUTOMATIC_ANALYSIS_FOR_CATALOG. This is similar to your _CHANGE_AUTOMATIC_ANALYSIS but instead of signaling a task that signals a task like in your code. I just have the lowest level task itself look at the value and do the right thing. I avoid the cancel problem entirely but just having it sit in a loop when it shouldn't be doing any analyzing.

Hope my explanation helps some...

@rorour
Copy link
Contributor Author

rorour commented Aug 6, 2024

This is a great simplification. I started to lose the forest for the trees with this one.

@e-carlin
Copy link
Member

e-carlin commented Aug 7, 2024

I'm glad it was helpful.

I wanted to try and figure out again what the rules are around create_task and awaits. I came across this issue. This async python stuff is tricky and even the creators of it don't have it all nailed down...

@e-carlin e-carlin enabled auto-merge (squash) August 7, 2024 16:24
@e-carlin e-carlin merged commit 23a7fcb into master Aug 7, 2024
3 checks passed
@e-carlin e-carlin deleted the 7153-raydata-auto-process branch August 7, 2024 16:48
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.

3 participants