Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/code-style-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
# - name: Run mypy
# run: mypy ./

- name: Run Flake8
run: flake8

- name: Run Black
run: black --check --diff .
# changed-python-files could be an empty string, which would cause `ruff check` to be run against the entire project.
- name: Run Ruff Linter
if: steps.changed-python-files.outputs.all_changed_files != ''
run: ruff check ${{ steps.changed-python-files.outputs.all_changed_files }}
4 changes: 1 addition & 3 deletions brus_backend_common/helpers/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
Internet RFC on Relative Uniform Resource Locators
Format: scheme://netloc/path;parameters?query#fragment
List of supported schemes: {}
""".format(
supported_schemes
)
""".format(supported_schemes)


def parse_http_url(http_url: str) -> Tuple[Any, Any | None, Any]:
Expand Down
2 changes: 1 addition & 1 deletion brus_backend_common/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
LookupType("04", "project grant (B)"),
LookupType("05", "cooperative agreement (B)"),
LookupType(
"06", "direct payment for specified use, as a subsidy or other non-reimbursable direct financial aid " "(C)"
"06", "direct payment for specified use, as a subsidy or other non-reimbursable direct financial aid (C)"
),
LookupType("07", "direct loan (E)"),
LookupType("08", "guaranteed/insured loan (F)"),
Expand Down
4 changes: 3 additions & 1 deletion brus_backend_common/models/lakehouse_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ def safe_literal_eval(val: Any) -> Any:
}
params.update(kwargs)

return pd.read_csv(io.BytesIO(self._s3_object), **params)[list(self.STRUCTURE.columns)] if self.exists() else None # type: ignore
return (
pd.read_csv(io.BytesIO(self._s3_object), **params)[list(self.STRUCTURE.columns)] if self.exists() else None
) # type: ignore

def to_polars_df(self, **kwargs: Any) -> pl.DataFrame | pl.Series | None:
return pl.read_csv(self.CSV_PATH, **kwargs) if self.exists() else None
Expand Down
2 changes: 2 additions & 0 deletions brus_backend_common/models/migrations/add_test_column.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from brus_backend_common.models.lakehouse_model import DeltaModel


def migrate(model: DeltaModel):
if model.spark:
sql_string = f"""
Expand All @@ -8,6 +9,7 @@ def migrate(model: DeltaModel):
"""
model.spark.sql(sql_string)


def reverse_migrate(model: DeltaModel):
if model.spark:
sql_string = f"""
Expand Down
2 changes: 2 additions & 0 deletions brus_backend_common/models/migrations/drop_test_column.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from brus_backend_common.models.lakehouse_model import DeltaModel


def migrate(model: DeltaModel):
if model.spark:
sql_string = f"""
Expand All @@ -16,6 +17,7 @@ def migrate(model: DeltaModel):
"""
model.spark.sql(sql_string)


def reverse_migrate(model: DeltaModel):
if model.spark:
sql_string = f"""
Expand Down
1 change: 0 additions & 1 deletion brus_backend_common/scripts/loaders/defc_gold.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def main(local_file: str | None = None, force_reload: bool = False, metrics_json
clean_df, gold_model.to_pandas_df(), ["defc_id"], ["code"], date_format="%Y-%m-%d"
)
if force_reload or diff_found:

# The only diff should be whenever a new code is added. Noting it here
if diff_found:
incoming_defcs = list(clean_df["code"])
Expand Down
2 changes: 1 addition & 1 deletion brus_backend_common/tests/integration/test_spark_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_spark_write_csv_app_run(spark: SparkSession, s3_unittest_data_bucket):

df = spark.createDataFrame([Row(**data_row) for data_row in data])
# NOTE! NOTE! NOTE! MinIO locally does not support a TRAILING SLASH after object (folder) name
df.write.option("header", True).csv(f"s3a://{s3_unittest_data_bucket}" f"/write_to_s3")
df.write.option("header", True).csv(f"s3a://{s3_unittest_data_bucket}/write_to_s3")

# Verify there are *.csv part files in the chosen bucket
s3_client = _get_boto3("client", "s3")
Expand Down
38 changes: 19 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ dependencies = [

[project.optional-dependencies]
dev = [
"black==25.1.0",
"docker==7.0.0",
"Flake8-pyproject==1.2.4",
"flake8==7.0.0",
"pytest==8.2.0",
"pytest-cov==4.1.0",
"pytest-pretty==1.3.0",
"pytest-xdist==3.7.0",
"requests-mock==1.12.1",
"ruff==0.14.14",
]
spark = [
"delta-spark==2.4.0",
Expand All @@ -94,10 +92,25 @@ awscli = [
"awscli==1.32.58",
]

[tool.black]
[tool.ruff]
line-length = 120
target-version = ['py312']
exclude = '/(\.git|\.venv|venv|migrations)/'
target-version = 'py312'

[tool.ruff.format]
line-ending = "lf"

[tool.ruff.lint]
preview = true # enable new rules
select = ['C','E','F','W','B']
ignore = ['E203','E501','F541','W605']
exclude = [
'.git',
'.venv',
'venv',
'**/migrations/**',
'build',
'brus-backend-common.egg-info'
]


[tool.coverage.run]
Expand Down Expand Up @@ -140,16 +153,3 @@ markers = [
pythonpath = [
"."
]

[tool.flake8]
select = ['C','E','F','W','B','B950']
ignore = ['E501','W503','E203','F541','E704']
extend-ignore = ['W605','W503','E203']
exclude = [
'.venv',
'venv',
'build',
'brus_backend_common.egg-info',
'brus_backend_common/*/migrations/*'
]
max-line-length = 120
Loading
Loading