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

DT-7143 use uv and ruff #26

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

DT-7143 use uv and ruff #26

wants to merge 4 commits into from

Conversation

njmei
Copy link
Collaborator

@njmei njmei commented Mar 11, 2025

This PR addresses DT-7143: https://alleninstitute.atlassian.net/browse/DT-7143

It replaces black, and isort dependencies with ruff and also starts using uv for our dependency/env manager

I would recommend browsing by commit

Notes:

@njmei njmei force-pushed the DT-7143-use-uv-and-ruff branch from f201426 to 9fe5e77 Compare March 11, 2025 20:33
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 93.54839% with 4 lines in your changes missing coverage. Please review.

Project coverage is 87.97%. Comparing base (efb85d3) to head (be7d979).

Files with missing lines Patch % Lines
src/aibs_informatics_aws_utils/ecr/core.py 84.61% 1 Missing and 1 partial ⚠️
src/aibs_informatics_aws_utils/batch.py 50.00% 1 Missing ⚠️
...aibs_informatics_aws_utils/ecr/image_replicator.py 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   87.98%   87.97%   -0.01%     
==========================================
  Files          37       37              
  Lines        3347     3361      +14     
  Branches      485      489       +4     
==========================================
+ Hits         2945     2957      +12     
- Misses        304      307       +3     
+ Partials       98       97       -1     
Files with missing lines Coverage Δ
src/aibs_informatics_aws_utils/__init__.py 100.00% <100.00%> (ø)
src/aibs_informatics_aws_utils/apigateway.py 94.11% <100.00%> (ø)
src/aibs_informatics_aws_utils/athena.py 89.79% <ø> (-0.59%) ⬇️
src/aibs_informatics_aws_utils/auth.py 86.36% <ø> (-0.60%) ⬇️
src/aibs_informatics_aws_utils/core.py 95.52% <100.00%> (+0.03%) ⬆️
...aibs_informatics_aws_utils/data_sync/operations.py 90.58% <100.00%> (ø)
.../aibs_informatics_aws_utils/dynamodb/conditions.py 99.23% <100.00%> (ø)
...c/aibs_informatics_aws_utils/dynamodb/functions.py 81.46% <100.00%> (ø)
src/aibs_informatics_aws_utils/dynamodb/table.py 94.11% <ø> (ø)
src/aibs_informatics_aws_utils/ec2.py 93.14% <100.00%> (+0.24%) ⬆️
... and 17 more
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


install-force: clean-install-stamp install ## Force install package dependencies
install-dev: .uv ## Installs development (dev/lint) related dependencies
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand you are trying to make these targets more granular, but for the sake of consistency with all our other packages, does it not make sense to have install make target install all of the dev dependencies? It is already installing dev, by default. especially since this makefile is used only by internal devs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

if you really want to have a target for only installing the source, could we make an explicit target that calls uv sync --frozen --no-default-groups (since make install is already installing half of these dev deps already).


tox: $(INSTALL_STAMP) ## Run Test in tox environment
$(VENV_BIN)/tox
pytest: install ## Run test (pytest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

based on the way targets are defined above, I dont think pytest or any test dependencies would be installed properly based on this target dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I stand corrected. the dev dependency group is always synced by default. This can be updated by updating the default-groups configuration field but the default for default-groups is dev https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-groups

[project.optional-dependencies]
# For dev dependencies: https://peps.python.org/pep-0735/
# See also: https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-groups
[dependency-groups]
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe it makes sense to specify default-groups to include lint in addition to dev?

default-groups=['dev', 'lint']

logger.error(error_msg)
raise AWSError(error_msg)
try:
region = AWSRegion(region)
assert region is not None
Copy link
Collaborator

Choose a reason for hiding this comment

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

why would this ever not be none?

@@ -144,8 +144,9 @@ def fix_collisions(
other (ConditionExpressionComponents): the other Expression Condition to modify

Returns:
ConditionExpressionComponents: The other, as a modified non-overlapping Expression Condition
"""
ConditionExpressionComponents: The other, as a modified
Copy link
Collaborator

Choose a reason for hiding this comment

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

did ruff split this docstring in the following way? I thought that the noqa: E501 didnt ignored the line length.

Comment on lines +234 to +235
if regions:
normalized_regions = regions
Copy link
Collaborator

Choose a reason for hiding this comment

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

could this not be done as a list comprehension? normalized_regions = regions or [None]

Comment on lines +301 to +304
normalized_regions: list[str] | list[None] = [None]
if regions:
normalized_regions = regions

Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment as above

@@ -345,7 +347,8 @@ def __post_init__(self):
imageIds=[dict(imageDigest=self.image_digest)],
)

if len(response["images"]) == 0 or "imageManifest" not in response["images"][0]:
no_images = len(response["images"]) == 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

did ruff complain about the previous implementation?

Comment on lines +568 to +569
if tags is None:
tags = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

did ruff complain about the previous implementation?

images = sorted(repo.get_images("TAGGED"), key=lambda _: _.image_pushed_at)

def get_image_push_time(image: ECRImage) -> datetime:
if image.image_pushed_at is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this be none ever?

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.

2 participants