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

feat: workflows python package and common container for them #184

Merged
merged 9 commits into from
Jul 31, 2024

Conversation

cardoe
Copy link
Contributor

@cardoe cardoe commented Jul 29, 2024

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.

@cardoe cardoe force-pushed the workflow-pkg branch 4 times, most recently from 6a1f2ef to 21f445e Compare July 29, 2024 18:57
@cardoe cardoe changed the title feat: workflow pkg WIP feat: workflows python package and common container for them Jul 29, 2024
@cardoe
Copy link
Contributor Author

cardoe commented Jul 29, 2024

Not ready for full review but pinging @mfencik, @skrobul, @stevekeay and @micahculpepper to see if they're okay with the approach.

@cardoe cardoe force-pushed the workflow-pkg branch 3 times, most recently from f8032f9 to 4c956a8 Compare July 30, 2024 03:05
@cardoe cardoe marked this pull request as ready for review July 30, 2024 03:07
@cardoe
Copy link
Contributor Author

cardoe commented Jul 30, 2024

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 poetry or hatch. What say the reviewers?

@skrobul
Copy link
Collaborator

skrobul commented Jul 30, 2024

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 poetry or hatch. What say the reviewers?

We also use poetry on other UC projects, can we replace the neutron plugin mechanism and standardise on poetry everywhere?

@nicholaskuechler
Copy link
Contributor

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 poetry or hatch. What say the reviewers?

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

@cardoe cardoe force-pushed the workflow-pkg branch 16 times, most recently from 8e5046a to 9b6210f Compare July 30, 2024 18:19
@cardoe cardoe force-pushed the workflow-pkg branch 3 times, most recently from dbce971 to ffcc997 Compare July 30, 2024 20:37
@cardoe cardoe requested a review from a team July 30, 2024 20:41
Copy link
Collaborator

@skrobul skrobul left a 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.

.pre-commit-config.yaml Outdated Show resolved Hide resolved
containers/Dockerfile.ironic-nautobot-client Outdated Show resolved Hide resolved
Comment on lines -10 to +25
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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

cardoe added 3 commits July 31, 2024 09:05
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.
cardoe added 6 commits July 31, 2024 10:16
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
@cardoe cardoe requested a review from skrobul July 31, 2024 15:19
Copy link
Collaborator

@skrobul skrobul left a comment

Choose a reason for hiding this comment

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

+1

@cardoe cardoe merged commit e41e591 into main Jul 31, 2024
13 checks passed
@cardoe cardoe deleted the workflow-pkg branch July 31, 2024 17:40
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