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

Step: load page: When a certain error appears, keep trying to reload the page until the full timeout is up. #367

Closed
plocket opened this issue Aug 3, 2021 · 1 comment · Fixed by #368
Assignees

Comments

@plocket
Copy link
Collaborator

plocket commented Aug 3, 2021

Not sure quite how to do this yet. Details:

More tests are failing more often now with a particular system error. It's quick and the error is something like ModuleNotFoundError: No module named 'docassemble.playground123testingsomebranchname'.

When working on loading the page, I had asked in docassemble about a da system page error that occurred when things were still reloading. I think I said something about the server reloading. The conversation seemed to indicate it would just cause a timeout. That info prompted the current code that ends quickly when detecting a system error.

With this new error message in hand, we're able to see that there might indeed be a system error when a project (module?) is not finished reloading:

When my selenium-like code creates a project and pulls github code, it waits till test.yml can load for that project. When it immediately thereafter tries to load an actual interview file (that does really exist), it sometimes gets the ModuleNotFoundError . E.g. ModuleNotFoundError: No module named 'docassemble.playground***testing155askquestion'. What might be going on?

Maybe the server is still in the middle of restarting and some threads have the updated module and others don't.

That means we need to change how this is working, but still retain the ability to have useful error messages.

Something like: If this particular error message comes up, if the timeout isn't up, keep trying to reload.

One thing that would help with this is: change the test run so that things fail when the setup fails [#55]. That way, we'll know if the code didn't get there at all or whether it's just not done reloading.

[Edit: That alone won't be enough to tell what kind of situation we're running into. The test.yml could load and then the error could turn up and it may not mean the package still needs to load and just needs extra time. It may be because the code was never able to get pulled. Just saying that failing on setup won't solve the main problem. test.yml just lets us know that the server itself is working.]

@plocket
Copy link
Collaborator Author

plocket commented Aug 4, 2021

About the server restarting on a pull:

Pull requests only sometimes cause server restarts - when they contain modules in them. Sometimes test.yml will be able to open sooner than other files. That's because when the server is restarting, files that don't contain references to modules will be able to restart faster than files that do. test.yml is free of modules - it doesn't import anything. For that reason, it'll be able to restart sooner. Our interview files may often contain references to modules and so they won't be able to restart till absolutely everything else is ready.

tl;dr

If I was automating this through selenium I would do the pull and then wait until the Packages page reappeared.
If the server doesn't need to restart, the user will go to the Packages page directly, but if the server needs to restart it will go to the restart waiting screen and then redirect to the Packages screen.

Note: There may be a way to tell when pulling a package doesn't work.

  1. When the repo url is wrong, there is probably an error message of some kind.
  2. When the branch name is wrong, the dropdown won't have the right branch name selected or present in it.
    We can make an issue to add detecting those problems and giving more useful error messages.

Longer

The conversation about it that was in Slack:

Question:

  1. The code pulls the package in
  2. The code waits for test.yml to load to make sure the server’s all set
  3. The code starts an interview that was pulled in with the package - the one that the developer specifies. There’s a race condition then. Sometimes the file loads and sometimes it gets the error I mentioned. Waiting does let the interview load properly.
    I need to handle other cases too, but that’s the current behavior I’m talking about.

Answer:

The server doesn't need to restart for data files in Playground packages to be available. However, in order to be able to use Python code to import a Playground package that has just been created, the server needs to restart, and finish restarting.
In https://docassemble.org/docs/api.html#playground_install there is an option to restart the server or not. A restart is only necessary if you change a module file. In the UI you can manually create a new Playground project and create a test.yml file and run it, and you never need to wait for the server to restart. But if you go in the Playground -> Modules and create or edit a .py file, you have to wait for the server to restart.

So when you pull a package, test.yml itself will be available right away. But if your interview depends on a Python module, then the interview won't work until the server finishes restarting. That is why the UI makes the user wait for the server to restart if a module file changes or is added.

Q:

That’s clarifying in some ways. There are still nuances I don’t understand. Let’s start here: why is it that when we pull from github, I sometimes can’t run test.yml if the server is not restarting?

A:

When you do a pull in the front end, it looks at the files in the package to see if there is a module file. If there is a module file in the package, the server restarts afterward. If there is not a module file, it does not make the user wait for a restart.

Q:

Ok, so it sounds like that’s the situation we’re dealing with - sometimes the server is restarting when the code is pulled. The code doesn’t do anything other than pull. No files are edited in any other way. So, the next thing I’m thinking: In both those cases, my code waits for test.yml to load. From what you’ve described so far, that is an indication that the server has at least somewhat finished restarting. As you’ve said, in some cases not everything has finished restarting. Thus the interview file doesn’t load. In those cases, is there a way to know that the only thing needed is more time?

A:

The server will also refrain from restarting if it detects that no module file has changed.
If I was automating this through selenium I would do the pull and then wait until the Packages page reappeared.
If the server doesn't need to restart, the user will go to the Packages page directly, but if the server needs to restart it will go to the restart waiting screen and then redirect to the Packages screen.

Before the server has finished restarting, a YAML file in the package might load, but it might fail due to a required package not being available to Python.

plocket added a commit that referenced this issue Aug 4, 2021
needs to give a chance for the module to reload. Also, added
another check to the setup pull as per instructions. See issue
comment for details. That should supposedly help this not happen,
but I did add a line in the report if it still happens and we'll
hopefully be able to see if that's not working and then report on
it.

Hope these are enough to fix this problem finally, but I don't know
of a way to test this.
plocket added a commit that referenced this issue Aug 6, 2021
Close #367, fix erroring too soon on no module error which
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 a pull request may close this issue.

1 participant