-
Notifications
You must be signed in to change notification settings - Fork 120
Adtisdal/cumulus 4427 add pdr cleanup #4212
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
base: master
Are you sure you want to change the base?
Conversation
c5a1bfc to
92fec12
Compare
reweeden
left a comment
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.
Looks pretty good! Just some ideas / food for thought mostly about best practice things that we might want to standardize...
| cp ./src/*/*.py ./dist/ | ||
| cp -r ./schemas ./dist/ | ||
|
|
||
| cd ./dist || exit 1 | ||
|
|
||
| node ../../../bin/zip.js lambda.zip $(ls | grep -v lambda.zip) |
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 ran into having to make the same modifications to this script. @paulpilone and I talked about possibly moving it to the top level bin folder so it doesn't need to be copy/pasted for every task. The thing I'm concerned with is slight drift between all the different versions over time.
tasks/pdr-cleanup/deploy/main.tf
Outdated
| source_code_hash = filebase64sha256("${path.module}/../dist/lambda.zip") | ||
| handler = "pdr_cleanup.handler" | ||
| role = var.lambda_processing_role_arn | ||
| runtime = "python3.13" |
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 believe our python version is 3.12. Are we trying to keep all the tasks on the same version?
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 downgraded to 3.12 to keep things consistent
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.
Should we be calling this task.py? I think in the best practices example there is a task.py and it makes sense to me for the 'entrypoint' (lambda handler) to always be in a file with the same name for all the tasks, but I'm not sure if that was actually the intention, so just an idea for discussion here.
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 wasn't sure if task.py was a filler name or not
| event (dict): A lambda event object | ||
| context (dict): An AWS Lambda context |
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'm also wondering about the docstring convention here. I think I ended up using the :param event: blah... convention (which I'm forgetting what it's called). I think it would be nice to pick one and have it be consistent across our python code.
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 don't have an opinion on the docstring stuff. Which ever one we pick I'll switch to!
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.
@bhazuka Do you have a preference?
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 don't have a preference. Honestly, I generally just look for a quick summary of what the class or function is for and rely on typing for input/output unless there is something not readily intuitive.
I would say stay to a standard if you want to add params, etc. Either go with the google style guide for comments/docstings, numpy styling, or reStructuredText Docstring that looks like this
def add_numbers(x: int, y: int) -> int:
"""Returns the sum of two integers.
:param x: The first integer.
:type x: int
:param y: The second integer.
:type y: int
:returns: The sum of the two integers.
:rtype: int
:raises ValueError: if x or y is not an integer.
"""
if not isinstance(x, int) or not isinstance(y, int):
raise ValueError("x and y must be integers")
return x + yWhatever you guys want to choose, let me know and I will update the best practices.
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 switched it over to the reStructuredText so they should be consistent now
|
|
||
| try: | ||
| s3_client.delete_object(Bucket=provider["host"], Key=src_path) | ||
| logger.info(f"DELETED: {provider['host']}/{src_path}") |
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.
How do we feel about using format strings in logger calls? I thought usually the linter complains about this, but I guess it's not in the default lints or the lints we turned on.
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'm open to switching to an alternative
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've been using the '%' style formatting built in to the logging lib https://docs.astral.sh/ruff/rules/logging-f-string/
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.
We could consider turning on some additional relevant lints
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 switched formats and I added in the check here
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.
actually nvm I removed the lint (kept the format changes) since there's a few other places outside this PR we'd have to update the logging statements
tasks/pdr-cleanup/tests/unit_tests/pdr_cleanup/test_pdr_cleanup.py
Outdated
Show resolved
Hide resolved
b01c24c to
2c11757
Compare
2c11757 to
7b995e6
Compare
Summary: Summary of changes
Addresses CUMULUS-4471: Coreify PDR Cleanup task
Changes
PR Checklist
📝 Note:
For most pull requests, please Squash and merge to maintain a clean and readable commit history.