rdxz2-utill 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rdxz2-utill might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdxz2-utill
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Your daily Python utility
5
5
  Author-email: Richard Dharmawan <richard.dharmawan@gmail.com>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
- rdxz2_utill-0.1.0.dist-info/licenses/LICENSE,sha256=PF9CUvzP8XFYopEAzrMzSCovF7RdBdscPqJCDC6KjPc,1073
1
+ rdxz2_utill-0.1.2.dist-info/licenses/LICENSE,sha256=PF9CUvzP8XFYopEAzrMzSCovF7RdBdscPqJCDC6KjPc,1073
2
2
  utill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- utill/my_bq.py,sha256=1BKjYa05yfOBInm245373lfi4sbOZKybYXdYmON2npM,24985
3
+ utill/my_bq.py,sha256=Y2zNCx7V71N8iNNEE-IB3KQuQDUeV7ZQbLJ4jY-N12Q,25108
4
4
  utill/my_compare.py,sha256=619QbVk3GihWxen95yVnivKHkah8GgPTLGiSkgHxykw,886
5
5
  utill/my_const.py,sha256=88dOqn6NPQ5-hfRqdkew5POoAIyO91XXOGvN76oNsdo,251
6
6
  utill/my_csv.py,sha256=AT5sAbAlYqnAmNgQMTSqEueRXM4D42yNPb5C3Hedy6c,2921
@@ -9,7 +9,7 @@ utill/my_dict.py,sha256=jPaPfdn4WYpm0uIBPiYFinpHhx1jXpFVDJ9npmvxGZQ,391
9
9
  utill/my_encryption.py,sha256=SCF7PPur39cW4RHidsRhw-9BZP-ymUH-6LZ9nAHJDsY,2105
10
10
  utill/my_env.py,sha256=E7XW3fuhxbDlFqmLPHrziJJZVRogzGh6rfQdyNV49f8,2130
11
11
  utill/my_file.py,sha256=-b6_dGDDBdS228kgwTYpmIa3vxW1c1TtWrLdzdlHjKY,1873
12
- utill/my_gcs.py,sha256=VBJ8lsJ-fHr_BzMoSuT5JUrvxidGyMc2VNtE6Um1T_M,3060
12
+ utill/my_gcs.py,sha256=qFH47gQmk6_v0DajihymX7Xx1ZVp4xWuxDQh90PrY0g,3088
13
13
  utill/my_input.py,sha256=OyKLoutXpwISReltuL_Gw2oojv16tYWJqQpqabBOQx4,350
14
14
  utill/my_json.py,sha256=WgW6mavGhfs4h1N5XbhsDnRk2dbh_ttJWdJUj4iWDN4,1473
15
15
  utill/my_mb.py,sha256=IyrySs92TqtjBUvPMeUN3P2kRK8EttTFRPZsv5Cr-xw,15090
@@ -28,8 +28,8 @@ utill/cmd/_pg.py,sha256=RVxEiSifyIwMDYDM69vt6WSLdVDr1cMzY6r4T2PzNRA,492
28
28
  utill/cmd/utill.py,sha256=TlHfiwOUcK1m58PrRCjX9sARiPYZUsoTk-KOTCOz1vM,3558
29
29
  utill/templates/mb.json,sha256=M46ZHSaSh4rbD_KGUViGr2B2ZV8_PC-O5Evqi35JK5g,59
30
30
  utill/templates/pg.json,sha256=LkJt0VV3zcyt7Tpn6gulsoVQgUc-9uImXOStvzu8cdU,271
31
- rdxz2_utill-0.1.0.dist-info/METADATA,sha256=iB4cHw4zIQnP_2DHvIkBpwKxR5s32RVXr9xyJiY-GX4,4401
32
- rdxz2_utill-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- rdxz2_utill-0.1.0.dist-info/entry_points.txt,sha256=9n5NWz5Wi9jDvYhB_81_4icgT5xABZ-QivHD8ibcafg,47
34
- rdxz2_utill-0.1.0.dist-info/top_level.txt,sha256=tuAYZoCsr02JYbpZj7I6fl1IIo53v3GG0uoj-_fINVk,6
35
- rdxz2_utill-0.1.0.dist-info/RECORD,,
31
+ rdxz2_utill-0.1.2.dist-info/METADATA,sha256=6tzVkvnpQcGVE24Zn3Z__yGHJeyP-mopwN35cY_gMiw,4401
32
+ rdxz2_utill-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ rdxz2_utill-0.1.2.dist-info/entry_points.txt,sha256=9n5NWz5Wi9jDvYhB_81_4icgT5xABZ-QivHD8ibcafg,47
34
+ rdxz2_utill-0.1.2.dist-info/top_level.txt,sha256=tuAYZoCsr02JYbpZj7I6fl1IIo53v3GG0uoj-_fINVk,6
35
+ rdxz2_utill-0.1.2.dist-info/RECORD,,
utill/my_bq.py CHANGED
@@ -178,7 +178,8 @@ class BQ():
178
178
  schema_str = ',\n'.join([column['name'] for column in schema])
179
179
  query_parts.append(f'(\n{schema_str}\n)')
180
180
  if table_options:
181
- query_parts.append(f'OPTIONS (\n{",\n".join(table_options)}\n)')
181
+ table_options_str = ',\n'.join(table_options)
182
+ query_parts.append(f'OPTIONS (\n{table_options_str}\n)')
182
183
  else:
183
184
  logger.debug('Table not exist, constructing CREATE TABLE query ...')
184
185
  query_parts = [
@@ -193,7 +194,8 @@ class BQ():
193
194
  clustering_fields_str = ', '.join([f'`{field}`' for field in clustering_fields])
194
195
  query_parts.append(f'CLUSTER BY {clustering_fields_str}')
195
196
  if table_options:
196
- query_parts.append(f'OPTIONS (\n{",\n".join(table_options)}\n)')
197
+ table_options_str = ',\n'.join(table_options)
198
+ query_parts.append(f'OPTIONS (\n{table_options_str}\n)')
197
199
  query_parts.append('AS')
198
200
  query_parts.append(textwrap.dedent(query).strip())
199
201
 
@@ -397,7 +399,7 @@ class BQ():
397
399
  for tmp_blobs in gcs.list_blobs(dst_gcs_prefix):
398
400
  local_tmp_filepath = os.path.join(tmp_dirname, tmp_blobs.name.split('/')[-1])
399
401
  gcs.download(tmp_blobs, local_tmp_filepath, move=True)
400
- logger.debug(f'Downloaded {tmp_blobs.name} to {local_tmp_filepath}')
402
+ # logger.debug(f'Downloaded {tmp_blobs.name} to {local_tmp_filepath}')
401
403
  local_tmp_filepaths.append(local_tmp_filepath)
402
404
 
403
405
  # Combine downloaded files
@@ -433,7 +435,7 @@ class BQ():
433
435
  for part in range(parts):
434
436
  dst_filepath_part = f'{dst_filepath.removesuffix(".csv")}_{part + 1:06}.csv'
435
437
  _export_download_combine(
436
- f'SELECT * EXCEPT(_rn) FROM `{tmp_table_fqn_rn}` WHERE _rn BETWEEN {(part * csv_row_limit) + 1} AND {(part + 1) * csv_row_limit}',
438
+ f'SELECT * EXCEPT(_rn) FROM `{tmp_table_fqn_rn}` WHERE _rn BETWEEN {(part * csv_row_limit) + 1} AND {(part + 1) * csv_row_limit} ORDER BY _rn',
437
439
  dst_gcs_prefix=gcs.build_tmp_dirpath(),
438
440
  dst_filepath=dst_filepath_part,
439
441
  )
utill/my_gcs.py CHANGED
@@ -16,7 +16,7 @@ class GCS:
16
16
 
17
17
  self.client = storage.Client(project=project_id or envs.GCP_PROJECT_ID)
18
18
  self.bucket = self.client.bucket(bucket or envs.GCS_BUCKET)
19
- logger.debug(f'GCS client open, project: {self.client.project}')
19
+ logger.debug(f'GCS client open, project: {self.client.project}, bucket: {self.bucket.name}')
20
20
 
21
21
  def get_blob(self, blobpath: str) -> storage.Blob:
22
22
  return self.bucket.blob(blobpath)