dbt-common 1.29.0__py3-none-any.whl → 1.31.0__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.
dbt_common/__about__.py CHANGED
@@ -1 +1 @@
1
- version = "1.29.0"
1
+ version = "1.31.0"
@@ -600,6 +600,9 @@ def rename(from_path: str, to_path: str, force: bool = False) -> None:
600
600
  to_path = convert_path(to_path)
601
601
  is_symlink = path_is_symlink(to_path)
602
602
 
603
+ if from_path == to_path:
604
+ return
605
+
603
606
  if os.path.exists(to_path) and force:
604
607
  if is_symlink:
605
608
  remove_file(to_path)
dbt_common/invocation.py CHANGED
@@ -1,8 +1,8 @@
1
1
  import uuid
2
- from datetime import datetime
2
+ from datetime import datetime, timezone
3
3
 
4
4
  _INVOCATION_ID = str(uuid.uuid4())
5
- _INVOCATION_STARTED_AT = datetime.utcnow()
5
+ _INVOCATION_STARTED_AT = datetime.now(timezone.utc).replace(tzinfo=None)
6
6
 
7
7
 
8
8
  def get_invocation_id() -> str:
@@ -16,4 +16,4 @@ def get_invocation_started_at() -> datetime:
16
16
  def reset_invocation_id() -> None:
17
17
  global _INVOCATION_ID, _INVOCATION_STARTED_AT
18
18
  _INVOCATION_ID = str(uuid.uuid4())
19
- _INVOCATION_STARTED_AT = datetime.utcnow()
19
+ _INVOCATION_STARTED_AT = datetime.now(timezone.utc).replace(tzinfo=None)
dbt_common/record.py CHANGED
@@ -179,6 +179,7 @@ class Recorder:
179
179
 
180
180
  self._record_added = False
181
181
  self._recording_file: Optional[TextIO] = None
182
+ self._recording_file_lock = Lock()
182
183
  if mode == RecorderMode.RECORD and not in_memory:
183
184
  self._recording_file = open(current_recording_path, "w")
184
185
  self._recording_file.write("[")
@@ -200,16 +201,19 @@ class Recorder:
200
201
  self._counter += 1
201
202
 
202
203
  if self._recording_file is not None:
203
- if self._record_added:
204
- self._recording_file.write(",")
205
- try:
206
- dct = Recorder._get_tagged_dict(record, rec_cls_name)
207
- json.dump(dct, self._recording_file)
208
- self._record_added = True
209
- except Exception:
210
- json.dump(
211
- {"type": "RecordingError", "record_type": rec_cls_name}, self._recording_file
212
- )
204
+ # Lock recording file during streamed recording to avoid race conditions across recording threads
205
+ with self._recording_file_lock:
206
+ if self._record_added:
207
+ self._recording_file.write(",")
208
+ try:
209
+ dct = Recorder._get_tagged_dict(record, rec_cls_name)
210
+ json.dump(dct, self._recording_file)
211
+ self._record_added = True
212
+ except Exception:
213
+ json.dump(
214
+ {"type": "RecordingError", "record_type": rec_cls_name},
215
+ self._recording_file,
216
+ )
213
217
  else:
214
218
  if rec_cls_name not in self._records_by_type:
215
219
  self._records_by_type[rec_cls_name] = []
@@ -444,8 +448,9 @@ class AutoValues(DataClassJSONMixin):
444
448
  def _to_dict(self):
445
449
  return self.to_dict()
446
450
 
447
- def _from_dict(self, data):
448
- return self.from_dict(data)
451
+ @classmethod
452
+ def _from_dict(cls, data):
453
+ return cls.from_dict(data)
449
454
 
450
455
 
451
456
  def _record_function_inner(
@@ -530,16 +535,37 @@ def _record_function_inner(
530
535
  else:
531
536
  param_args = (getattr(args[0], id_field_name),) + param_args
532
537
 
533
- params = record_type.params_cls(*param_args, **kwargs)
538
+ # Build params - this can be dangerous if a subclass overrides the method in such a way that
539
+ # changes the signature of the base recorded method, and so is wrapped in a try/except.
540
+ params = None
541
+ try:
542
+ # Omits any additional properties that are not fields of the params class
543
+ params_dict = {
544
+ field.name: value
545
+ for field, value in zip(dataclasses.fields(record_type.params_cls), param_args)
546
+ }
547
+ params_dict.update(kwargs)
548
+ try:
549
+ params = record_type.params_cls._from_dict(params_dict)
550
+ except (TypeError, AttributeError):
551
+ params = record_type.params_cls(*param_args, **kwargs)
552
+ except Exception:
553
+ # Unfortunately it is not possible to fire an event here because it would cause a circular import
554
+ # This means we lose visibility into the issue, but it is better than crashing the entire node or command
555
+ pass
556
+ except Exception:
557
+ # Unfortunately it is not possible to fire an event here because it would cause a circular import
558
+ # This means we lose visibility into the issue, but it is better than crashing the entire node or command
559
+ pass
534
560
 
535
561
  include = True
536
- if hasattr(params, "_include"):
562
+ if params is not None and hasattr(params, "_include"):
537
563
  include = params._include()
538
564
 
539
565
  if not include:
540
566
  return func_to_record(*call_args, **kwargs)
541
567
 
542
- if recorder.mode == RecorderMode.REPLAY:
568
+ if recorder.mode == RecorderMode.REPLAY and params is not None:
543
569
  return recorder.expect_record(params)
544
570
  if RECORDED_BY_HIGHER_FUNCTION.get():
545
571
  return func_to_record(*call_args, **kwargs)
@@ -554,7 +580,8 @@ def _record_function_inner(
554
580
  else record_type.result_cls(r)
555
581
  )
556
582
  RECORDED_BY_HIGHER_FUNCTION.set(False)
557
- recorder.add_record(record_type(params=params, result=result))
583
+ if params is not None:
584
+ recorder.add_record(record_type(params=params, result=result))
558
585
  return r
559
586
 
560
587
  setattr(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbt-common
3
- Version: 1.29.0
3
+ Version: 1.31.0
4
4
  Summary: The shared common utilities that dbt-core and adapter implementations use
5
5
  Project-URL: Homepage, https://github.com/dbt-labs/dbt-common
6
6
  Project-URL: Repository, https://github.com/dbt-labs/dbt-common.git
@@ -1,13 +1,13 @@
1
- dbt_common/__about__.py,sha256=_rctfPDph1ATziwQ_Kw-ESD20nyypxJbuBbphV5sTK8,19
1
+ dbt_common/__about__.py,sha256=GY1J5mpmws_U4-5YJ7wyu27HoxTMfH6V135Ll8xlp6k,19
2
2
  dbt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  dbt_common/behavior_flags.py,sha256=hQzxCqQSweJbRp_xoQqNnlUF77PBuOdCdLOSdcBlkxk,4885
4
4
  dbt_common/constants.py,sha256=6ATQPXft7vw_vyhnmkGy3geKfuzWC3ZiUH4kuNuGQ5w,381
5
5
  dbt_common/context.py,sha256=w0XfTvQNxtuctHm8hxsdySFoInggBMQm2-7faa_7ObU,3317
6
6
  dbt_common/dataclass_schema.py,sha256=u2S0dxwxIghv8RMqC91HlWZJVxmsC_844yZQaGyOwdY,5563
7
7
  dbt_common/helper_types.py,sha256=wxbbjfsvHVraWexK88PEY3q_dAYqlPl6yOIXnpxCcyY,11569
8
- dbt_common/invocation.py,sha256=xw0NBIE-6LHd135cx4non-MkGGsia0mYN0lMkmNEucE,435
8
+ dbt_common/invocation.py,sha256=PzWsS7TJSfLzG1_Y3dq1fmfTDuZAjUN7794DglJqTTM,505
9
9
  dbt_common/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- dbt_common/record.py,sha256=DTVNnQhBOJvhpPF1xpoEdxbS7N7grPbaFHiFE-vjlMA,22375
10
+ dbt_common/record.py,sha256=ybe4Kyy9FJ_uc1K-0tk6Gv2cbD8kpdVIAy5APbrBWfQ,23965
11
11
  dbt_common/semver.py,sha256=Znewz6tc_NBpXr4mZf20bK_RayPL4ODrnxDbkUZrrRo,15034
12
12
  dbt_common/tests.py,sha256=6lC_JuRtoYO6cbAF8-R5aTM4HtQiM_EH8X5m_97duGY,315
13
13
  dbt_common/ui.py,sha256=geIk3ElFj5y_SG5EDc6RMJFEvYGdo-6C21l0pB8I-EU,2934
@@ -15,7 +15,7 @@ dbt_common/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
15
15
  dbt_common/clients/_jinja_blocks.py,sha256=eUjZLBtLCASJRRj1G8b9u15A3PQMDCKvytIdWkTLSP4,15451
16
16
  dbt_common/clients/agate_helper.py,sha256=anKKgKV5PSnFRuFeBwRMdHK3JCaQoUqB2ZXHD0su0Wo,9123
17
17
  dbt_common/clients/jinja.py,sha256=wKwBCtIGKXOwU-KWWF2sz77nST-JUP26U_Zo_a6mNe8,22756
18
- dbt_common/clients/system.py,sha256=aoUBtOuXVmkOyj6IhhJ3Y4a7JFzPO2F_zKyOtz3xy44,23932
18
+ dbt_common/clients/system.py,sha256=fn1bpskrOnp0fFz6QeOWzVD2jmLX7ShhueUe-2bgqEE,23977
19
19
  dbt_common/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  dbt_common/contracts/constraints.py,sha256=_f1q3Rkcg2UwA7zI5XBbUMXnPUg6pw17UC7l1HyhyQM,1352
21
21
  dbt_common/contracts/metadata.py,sha256=K_M06Rue0wmrQhFP_mq3uvQszq10CIt93oGiAVgbRfE,1293
@@ -56,7 +56,7 @@ dbt_common/utils/encoding.py,sha256=6_kSY2FvGNYMg7oX7PrbvVioieydih3Kl7Ii802LaHI,
56
56
  dbt_common/utils/executor.py,sha256=pNY0UbPlwQmTE69Vt_Rj91YGCIOEaqeYU3CjAds0T70,2454
57
57
  dbt_common/utils/formatting.py,sha256=JUn5rzJ-uajs9wPCN0-f2iRFY1pOJF5YjTD9dERuLoc,165
58
58
  dbt_common/utils/jinja.py,sha256=JXgNmJArGGy0h7qkbNLA3zaEQmoF1CxsNBYTlIwFXDw,1101
59
- dbt_common-1.29.0.dist-info/METADATA,sha256=WZmO2MH7Ay_LGjHIr-i6wNdcDOJnyt4jdsdk3VLYjm0,4988
60
- dbt_common-1.29.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
61
- dbt_common-1.29.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
62
- dbt_common-1.29.0.dist-info/RECORD,,
59
+ dbt_common-1.31.0.dist-info/METADATA,sha256=x-HIsYSHb3wM0wLFUwpa6dvgQLJGRmUzcj4qBHAfZBA,4988
60
+ dbt_common-1.31.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
61
+ dbt_common-1.31.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
62
+ dbt_common-1.31.0.dist-info/RECORD,,