Conversation
a3b937b to
8e09ec6
Compare
ehanson8
left a comment
There was a problem hiding this comment.
Great work! A few questions and suggestions
| "--queue", default=CONFIG.INPUT_QUEUE, help="Name of queue to process messages from" | ||
| "--queue", envvar="INPUT_QUEUE", help="Name of queue to process messages from" |
There was a problem hiding this comment.
Why change this from the Config attribute as the default? I thought our general practice was to only read env var in the Config class
There was a problem hiding this comment.
I've seen envvar used more frequently in our more current applications, and this is the syntax for it: https://click.palletsprojects.com/en/stable/options/#values-from-environment-variables (i.e., it accepts a string).
The order of precedence in Click is:
- A value provided on the command line will override an environment variable or default value.
- An environment variable will override the default value defined in the option decorator.
There was a problem hiding this comment.
It feels weird to me that we have all the logic in the Config module for processing env var and what to do if they're not there but then we're accessing directly through the CLI. Maybe this is a topic better reserved for a larger Config discussion but I would also appreciate @ghukill thoughts on this before proceeding
There was a problem hiding this comment.
For completeness, we could set:
envvar="INPUT_QUEUE"
default=Config.input_queueWhere envvar is insufficient is if you have to do something with the environment variable, like splitting by a delimiter.
| default=CONFIG.INPUT_QUEUE, | ||
| envvar="INPUT_QUEUE", |
| def dss_dspace_credentials(self) -> str: | ||
| value = os.getenv("DSS_DSPACE_CREDENTIALS") | ||
| if not value: | ||
| raise OSError("Env var 'DSS_DSPACE_CREDENTIALS' must be defined") |
There was a problem hiding this comment.
What about a check_required_env_vars method like we have in DSC to eliminate some of these checks in the properties?
There was a problem hiding this comment.
Hmm, I'd like to hold off on defining additional methods on the Config class until DataEng can have a more focused discussion on how we can standardize the format of this module (i.e., what methods to include, how to check required env vars).
In the case of development with DSC, I found it a hindrance that check_required_env_vars is called whenever you run the CLI, requiring the user to define all env vars even if only for local development.
In the latest version of python-lambdas-template, the method is defined, but it is not called when executed.
TLDR: Given that this works for now, I propose we move forward as is and discuss a better way to handle environment-specific required env var checking!
ehanson8
left a comment
There was a problem hiding this comment.
We can discuss a more standardized approach to the Config class soon so this is fine for now!
Why these changes are being introduced: * Prior to these changes, it was difficult to debug errors for failing ingests due to the setup of the `Config` class and how it configured logging. How this addresses that need: * Use a WARNING_ONLY_LOGGERS environment variable to minimize “noise” for select third-party libraries (e.g., [botocore, boto3, smart_open, urllib3]). * Support 'verbose' CLI option * Access env vars on Config via property methods * Update how/when Config is instantiated and logger is configured Side effects of this change: * This deprecates the 'LOG_FILTER' and 'LOG_LEVEL' environment variables for DSS, so the ECS Task Definition should also be updated. Relevant ticket(s): https://mitlibraries.atlassian.net/browse/IN-1679
f0db14d to
51725aa
Compare
Purpose and background context
Update the
configmodule to align with some of our current conventions for instantiation, env var access, and logging controls. Though we have not standardized our approaches to managing app configurations, the following properties/features were implemented for DSS:WARNING_ONLY_LOGGERSenvironment variable to minimize “noise” for select third-party libraries (e.g.,[botocore, boto3, smart_open, urllib3]).configure_loggerandconfigure_sentryare defined in the config module (but not as methods of the Config class itself).How can a reviewer manually see the effects of these changes?
DSS was run in Dev using a sample OpenCourseWare item submission and a test collection in DSpace 8.
Note: Ignore the very first logged message with
"VERBOSE: True"; was used for testing and has been removed.✨ We can now see the logged exceptions from
dspace-rest-pythonmore easilyNote: Recreated the error from IN-1687 by temporarily removing the DSS E-Person from the "Administrator" group in the DSpace 8 instance prior to running DSS.
Includes new or updated dependencies?
YES
Changes expectations for external applications?
YES; To see logs at
DEBUGlevel, users and calling apps must set--verbose / -vCLI option.What are the relevant tickets?
Code review