-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: workflows python package and common container for them #184
Conversation
6a1f2ef
to
21f445e
Compare
Not ready for full review but pinging @mfencik, @skrobul, @stevekeay and @micahculpepper to see if they're okay with the approach. |
f8032f9
to
4c956a8
Compare
I used setuptools cause that's what the neutron plugin used but it's really my least favorite choice cause it makes test dependencies painful (see the GitHub Actions test). I'd prefer |
We also use poetry on other UC projects, can we replace the neutron plugin mechanism and standardise on poetry everywhere? |
I'm +1 on poetry |
8e5046a
to
9b6210f
Compare
dbce971
to
ffcc997
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor suggestions and questions, but otherwise LGTM.
def setup_logger(name): | ||
logger = logging.getLogger(name) | ||
handler = logging.StreamHandler() | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(name)s - %(levelname)s - %(message)s" | ||
def setup_logger(name: str | None = None, level: int = logging.DEBUG): | ||
"""Standardize our logging. | ||
|
||
Configures the root logger to prefix messages with a timestamp | ||
and to output the log level we want to see by default. | ||
|
||
params: | ||
name: logger hierarchy or root logger | ||
level: default log level (DEBUG) | ||
""" | ||
logging.basicConfig( | ||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", | ||
level=logging.DEBUG, | ||
) | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
logger.setLevel(logging.DEBUG) | ||
return logger | ||
return logging.getLogger(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this change the format and level for root and all future loggers instead of affecting a single instance?
If so, is there a risk that loggers initialized later by the workflow code will spam too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But the result with an installed package is that all the helper modules will be parallel to the binary and won't produce any logging. Is that what we want out of the box?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that we may want to enable debug just for the code we own, not everything down the line. Let's try your version, we can always revert this later.
python/understack-workflows/understack_workflows/main/synchronize_interfaces.py
Outdated
Show resolved
Hide resolved
python/understack-workflows/understack_workflows/main/synchronize_obm_creds.py
Show resolved
Hide resolved
Perform style checks using ruff for our Python code. This drops using flake8 and black on that code as well.
Bring our Python workflow code into a package for consistency and code sharing.
Moved the sync-nb-server-to-ironic code into the our workflows python package. This required fixing up some places to craft the necessary entry points as well as setting dependencies. Removed the building of the container for the old directory and create a new container with these pieces.
The neutron container build needs packages to be able to install so it needs an index to get those from. It does not need to cache them in the container however.
Moved the sync-srv-redfish-intfs-to-nb code into the our workflows python package. This required fixing up some places to craft the necessary entry points as well as setting dependencies. Removed the building of the container for the old directory and add it into the common one.
Enabled pydocstyle checks to get some consistency on our documentation strings.
Hook up pytest to run tests for the package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Create a python package for our workflows code to standardize dependencies and code style. This allows us to share code between the workflows more easily as well. Created a common container for the workflows as well.