Skip to content

Commit 711131d

Browse files
committed
fix all linter errors
1 parent 11c402d commit 711131d

File tree

1 file changed

+34
-42
lines changed

1 file changed

+34
-42
lines changed

scripts/jobs/housing/rentsense_to_refined.py

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
import sys
2-
import boto3
3-
import io
4-
import zipfile
5-
from pyspark.sql import Window
6-
from pyspark.context import SparkContext
2+
from datetime import date
3+
4+
import pyspark.sql.functions as F
75
from awsglue.context import GlueContext
86
from awsglue.dynamicframe import DynamicFrame
9-
from awsglue.transforms import *
10-
from awsglue.utils import getResolvedOptions
117
from awsglue.job import Job
12-
from pyspark.sql.functions import *
13-
from pyspark.sql.types import IntegerType, StringType, FloatType
14-
from datetime import date
15-
import pyspark.sql.functions as f
8+
from awsglue.transforms import DropFields
9+
from awsglue.utils import getResolvedOptions
10+
from pyspark.context import SparkContext
11+
from pyspark.sql.functions import col, current_date, date_sub, lit, to_date
12+
1613
from scripts.helpers.helpers import (
17-
move_file,
18-
rename_file,
19-
get_glue_env_var,
20-
get_latest_partitions_optimized,
21-
create_pushdown_predicate,
22-
add_import_time_columns,
2314
PARTITION_KEYS,
24-
parse_json_into_dataframe,
25-
table_exists_in_catalog,
15+
add_import_time_columns,
2616
clear_target_folder,
17+
get_glue_env_var,
18+
get_latest_partitions_optimized,
19+
move_file,
20+
rename_file,
2721
)
2822

2923
# The block below is the actual job. It is ignored when running tests locally.
@@ -128,7 +122,7 @@
128122
"RHB": "Housing Benefit",
129123
"RIT": "Internal Transfer",
130124
"RML": "MW Loan Payment",
131-
"ROB": "\Opening Balance",
125+
"ROB": r"\Opening Balance",
132126
"RPD": "Prompt Pay. Discount",
133127
"RPO": "Postal Order",
134128
"RPY": "PayPoint/Post Office",
@@ -274,11 +268,10 @@
274268
"SMS": "Text message sent",
275269
"ACB": "Actual Cost Breakdown Sent",
276270
"TAA": "TA New Account checks",
277-
"RAP": "Outcome of rent arrears panel",
271+
"RAP": "Rent Arrears Panel Outcome",
278272
"PLA": "Pre legal action visit",
279273
"PEO": "Pre eviction contact outcome",
280274
"AAD": "Pre notice interview",
281-
"RAP": "Rent Arrears Panel Outcome",
282275
"DA4": "Referred to Credit Gee",
283276
"RT4": "Returned by Credit Gee",
284277
"ZW0": "MW Pre Arrears Completed",
@@ -300,7 +293,6 @@
300293
"RT3": "RETURNED BY LEWIS DEBT AGENCY",
301294
"INV": "ACTION ON HOLD",
302295
"MHB": "HB INVESTIGATION PENDING",
303-
"RT4": "Returned by Credit Gee",
304296
"MW0": "MW Pre Arrears",
305297
"MW1": "MW Letter Action 1",
306298
"MW2": "MW Letter Action 2",
@@ -575,17 +567,17 @@
575567
transformation_ctx="target_data_to_write",
576568
)
577569

578-
filename = f"/rent.accounts%s.csv.gz" % today.strftime("%Y%m%d")
570+
filename = "/rent.accounts%s.csv.gz" % today.strftime("%Y%m%d")
579571
rename_file(s3_bucket, "housing/rentsense/gzip/accounts", filename)
580572

581573
# move file to export folder
582-
target_path = f"housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
583-
# move_file("dataplatform-stg-refined-zone", "housing/rentsense/gzip/accounts/", target_path, f"rent.accounts%s.csv.gz" % today.strftime("%Y%m%d"))
574+
target_path = "housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
575+
# move_file("dataplatform-stg-refined-zone", "housing/rentsense/gzip/accounts/", target_path, "rent.accounts%s.csv.gz" % today.strftime("%Y%m%d"))
584576
move_file(
585577
s3_bucket,
586578
"housing/rentsense/gzip/accounts/",
587579
target_path,
588-
f"rent.accounts%s.csv.gz" % today.strftime("%Y%m%d"),
580+
"rent.accounts%s.csv.gz" % today.strftime("%Y%m%d"),
589581
)
590582

591583
# Arrangements
@@ -675,16 +667,16 @@
675667
)
676668

677669
today = date.today()
678-
filename = f"/rent.arrangements%s.csv.gz" % today.strftime("%Y%m%d")
670+
filename = "/rent.arrangements%s.csv.gz" % today.strftime("%Y%m%d")
679671
rename_file(s3_bucket, "housing/rentsense/gzip/arrangements", filename)
680672

681673
# move file to export folder
682-
target_path = f"housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
674+
target_path = "housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
683675
move_file(
684676
s3_bucket,
685677
"housing/rentsense/gzip/arrangements/",
686678
target_path,
687-
f"rent.arrangements%s.csv.gz" % today.strftime("%Y%m%d"),
679+
"rent.arrangements%s.csv.gz" % today.strftime("%Y%m%d"),
688680
)
689681

690682
# Tenants
@@ -802,16 +794,16 @@
802794
transformation_ctx="target_data_to_write",
803795
)
804796

805-
filename = f"/rent.tenants%s.csv.gz" % today.strftime("%Y%m%d")
797+
filename = "/rent.tenants%s.csv.gz" % today.strftime("%Y%m%d")
806798
rename_file(s3_bucket, "housing/rentsense/gzip/tenants", filename)
807799

808800
# move file to export folder
809-
target_path = f"housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
801+
target_path = "housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
810802
move_file(
811803
s3_bucket,
812804
"housing/rentsense/gzip/tenants/",
813805
target_path,
814-
f"rent.tenants%s.csv.gz" % today.strftime("%Y%m%d"),
806+
"rent.tenants%s.csv.gz" % today.strftime("%Y%m%d"),
815807
)
816808

817809
# Balances
@@ -877,16 +869,16 @@
877869
transformation_ctx="target_data_to_write",
878870
)
879871

880-
filename = f"/rent.balances%s.csv.gz" % today.strftime("%Y%m%d")
872+
filename = "/rent.balances%s.csv.gz" % today.strftime("%Y%m%d")
881873
rename_file(s3_bucket, "housing/rentsense/gzip/balances", filename)
882874

883875
# move file to export folder
884-
target_path = f"housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
876+
target_path = "housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
885877
move_file(
886878
s3_bucket,
887879
"housing/rentsense/gzip/balances/",
888880
target_path,
889-
f"rent.balances%s.csv.gz" % today.strftime("%Y%m%d"),
881+
"rent.balances%s.csv.gz" % today.strftime("%Y%m%d"),
890882
)
891883

892884
# Actions
@@ -963,16 +955,16 @@
963955
transformation_ctx="target_data_to_write",
964956
)
965957

966-
filename = f"/rent.actions%s.csv.gz" % today.strftime("%Y%m%d")
958+
filename = "/rent.actions%s.csv.gz" % today.strftime("%Y%m%d")
967959
rename_file(s3_bucket, "housing/rentsense/gzip/actions", filename)
968960

969961
# move file to export folder
970-
target_path = f"housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
962+
target_path = "housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
971963
move_file(
972964
s3_bucket,
973965
"housing/rentsense/gzip/actions/",
974966
target_path,
975-
f"rent.actions%s.csv.gz" % today.strftime("%Y%m%d"),
967+
"rent.actions%s.csv.gz" % today.strftime("%Y%m%d"),
976968
)
977969

978970
# Transactions
@@ -1052,16 +1044,16 @@
10521044
transformation_ctx="target_data_to_write",
10531045
)
10541046

1055-
filename = f"/rent.transactions%s.csv.gz" % today.strftime("%Y%m%d")
1047+
filename = "/rent.transactions%s.csv.gz" % today.strftime("%Y%m%d")
10561048
rename_file(s3_bucket, "housing/rentsense/gzip/transactions", filename)
10571049

10581050
# move file to export folder
1059-
target_path = f"housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
1051+
target_path = "housing/rentsense/export/%s/" % today.strftime("%Y%m%d")
10601052
move_file(
10611053
s3_bucket,
10621054
"housing/rentsense/gzip/transactions/",
10631055
target_path,
1064-
f"rent.transactions%s.csv.gz" % today.strftime("%Y%m%d"),
1056+
"rent.transactions%s.csv.gz" % today.strftime("%Y%m%d"),
10651057
)
10661058

10671059
job.commit()

0 commit comments

Comments
 (0)