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

Use sane environment by default #538

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

ambs
Copy link

@ambs ambs commented Jun 7, 2021

  • by default, the repository has debug enabled, meaning the get_debug_config is called
    overwriting the user config. That is not nice. Changed by default to false.
    In the future this can be a configuration flag?

  • when no config file is set, and debug is false, no configuration is loaded. This causes
    a lot of errors (namely key not founds). Given the repo includes a config file, added
    code to load it by default

  • when using the default config file, warn the user about that

Some details can be made better, but for now, it is working perfectly on my docker environment.
I am happy to provide further changes on this branch if you like.

 - by default, the repository has debug enabled, meaning the get_debug_config is called
   overwriting the user config. That is not nice. Changed by default to false.
   In the future this can be a configuration flag?

 - when no config file is set, and debug is false, no configuration is loaded. This causes
   a lot of errors (namely key not founds). Given the repo includes a config file, added
   code to load it by default

 - when using the default config file, warn the user about that

Some details can be made better, but for now, it is working perfectly on my docker environment.
I am happy to provide further changes on this branch if you like.
@bcail
Copy link
Contributor

bcail commented Jun 8, 2021

@ambs thanks - looks like there's an error to fix.

@@ -781,7 +798,7 @@ def _make_image(self, image_request, image_info):

sys.path.append(path.join(project_dp)) # to find any local resolvers

app = create_app(debug=True) # or 'opj'
app = create_app(debug=False) # or 'opj'
Copy link
Contributor

Choose a reason for hiding this comment

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

this run_simple() code here isn't meant for production use. Not sure we should change the debug default to false in create_app() - it might look like this is an approved way to run loris in production.

@alexwlchan any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I would leave the default as debug=true. Clear sign that this is only for local testing.

Copy link
Author

Choose a reason for hiding this comment

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

The problem is that it isn't documented, and it is not clear why some flags in the config file are being overwritten by the get_debug_config method. This function is my main concern. I do not think it is a problem to keep the debug as true if we honour the data from the config file, and not rewrite it.

@ambs
Copy link
Author

ambs commented Jun 8, 2021

I fixed the problem. It's not a clean solution yet.
I think you need to decide what to do with the get_debug_config function.
I suggest it just sets values if they are not present, and therefore, not rewriting anything.
If that seems like a good suggestion, let me know, and I'll prepare such a PR (and we can keep the debug=True option).

@bcail
Copy link
Contributor

bcail commented Jun 9, 2021

@ambs I think updating get_debug_config to just set values if they're not present - would be ok. That way configuration in the config file isn't overwritten, as you point out. However, to update get_debug_config, you might need to update the tests, which use that function. You might need to add a new function to set the correct config for the tests.

@ambs
Copy link
Author

ambs commented Jun 9, 2021

@bcail I am happy with that. It might take some more time to prepare a decent patch, but I will try to prepare it.
Just so I do not abuse CI, what is the correct way to run the tests locally?
Thank you

@bcail
Copy link
Contributor

bcail commented Jun 9, 2021

Take a look at the CI configuration: https://github.com/loris-imageserver/loris/blob/development/.github/workflows/ci.yml. That shows how to set up the environment for running the tests.

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