upgini 1.2.85__py3-none-any.whl → 1.2.86a1__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 upgini might be problematic. Click here for more details.
- upgini/__about__.py +1 -1
- upgini/autofe/feature.py +3 -2
- upgini/autofe/utils.py +28 -0
- upgini/http.py +36 -22
- {upgini-1.2.85.dist-info → upgini-1.2.86a1.dist-info}/METADATA +1 -1
- {upgini-1.2.85.dist-info → upgini-1.2.86a1.dist-info}/RECORD +8 -8
- {upgini-1.2.85.dist-info → upgini-1.2.86a1.dist-info}/WHEEL +1 -1
- {upgini-1.2.85.dist-info → upgini-1.2.86a1.dist-info}/licenses/LICENSE +0 -0
upgini/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "1.2.
|
1
|
+
__version__ = "1.2.86a1"
|
upgini/autofe/feature.py
CHANGED
@@ -8,6 +8,7 @@ from pandas._typing import DtypeObj
|
|
8
8
|
|
9
9
|
from upgini.autofe.all_operators import find_op
|
10
10
|
from upgini.autofe.operator import Operator, PandasOperator
|
11
|
+
from upgini.autofe.utils import pydantic_dump_method, pydantic_parse_method
|
11
12
|
|
12
13
|
|
13
14
|
class Column:
|
@@ -80,9 +81,9 @@ class Feature:
|
|
80
81
|
self.alias = alias
|
81
82
|
|
82
83
|
def set_op_params(self, params: Optional[Dict[str, str]]) -> "Feature":
|
83
|
-
obj_dict = self.op
|
84
|
+
obj_dict = pydantic_dump_method(self.op)().copy()
|
84
85
|
obj_dict.update(params or {})
|
85
|
-
self.op = self.op.__class__
|
86
|
+
self.op = pydantic_parse_method(self.op.__class__)(obj_dict)
|
86
87
|
self.op.set_params(params)
|
87
88
|
|
88
89
|
for child in self.children:
|
upgini/autofe/utils.py
CHANGED
@@ -81,3 +81,31 @@ def pydantic_validator(field_name: str, *fields, mode: str = "before", **kwargs)
|
|
81
81
|
return wrapper
|
82
82
|
|
83
83
|
return decorator
|
84
|
+
|
85
|
+
|
86
|
+
def pydantic_json_method(obj):
|
87
|
+
if get_pydantic_version() >= 2:
|
88
|
+
return obj.model_dump_json
|
89
|
+
else:
|
90
|
+
return obj.json
|
91
|
+
|
92
|
+
|
93
|
+
def pydantic_parse_method(cls):
|
94
|
+
if get_pydantic_version() >= 2:
|
95
|
+
return cls.model_validate
|
96
|
+
else:
|
97
|
+
return cls.parse_obj
|
98
|
+
|
99
|
+
|
100
|
+
def pydantic_dump_method(obj):
|
101
|
+
if get_pydantic_version() >= 2:
|
102
|
+
return obj.model_dump
|
103
|
+
else:
|
104
|
+
return obj.dict
|
105
|
+
|
106
|
+
|
107
|
+
def pydantic_copy_method(obj):
|
108
|
+
if get_pydantic_version() >= 2:
|
109
|
+
return obj.model_copy
|
110
|
+
else:
|
111
|
+
return obj.copy
|
upgini/http.py
CHANGED
@@ -24,6 +24,12 @@ from pythonjsonlogger import json as jsonlogger
|
|
24
24
|
from requests.exceptions import RequestException
|
25
25
|
|
26
26
|
from upgini.__about__ import __version__
|
27
|
+
from upgini.autofe.utils import (
|
28
|
+
pydantic_copy_method,
|
29
|
+
pydantic_dump_method,
|
30
|
+
pydantic_json_method,
|
31
|
+
pydantic_parse_method,
|
32
|
+
)
|
27
33
|
from upgini.errors import (
|
28
34
|
HttpError,
|
29
35
|
UnauthorizedError,
|
@@ -459,19 +465,19 @@ class _RestClient:
|
|
459
465
|
content = file.read()
|
460
466
|
md5_hash.update(content)
|
461
467
|
digest = md5_hash.hexdigest()
|
462
|
-
metadata_with_md5 = metadata
|
468
|
+
metadata_with_md5 = pydantic_copy_method(metadata)(update={"checksumMD5": digest})
|
463
469
|
|
464
470
|
# digest_sha256 = hashlib.sha256(
|
465
471
|
# pd.util.hash_pandas_object(pd.read_parquet(file_path, engine="fastparquet")).values
|
466
472
|
# ).hexdigest()
|
467
473
|
digest_sha256 = self.compute_file_digest(file_path)
|
468
|
-
metadata_with_md5 = metadata_with_md5
|
474
|
+
metadata_with_md5 = pydantic_copy_method(metadata_with_md5)(update={"digest": digest_sha256})
|
469
475
|
|
470
476
|
with open(file_path, "rb") as file:
|
471
477
|
files = {
|
472
478
|
"metadata": (
|
473
479
|
"metadata.json",
|
474
|
-
metadata_with_md5
|
480
|
+
pydantic_json_method(metadata_with_md5)(exclude_none=True).encode(),
|
475
481
|
"application/json",
|
476
482
|
),
|
477
483
|
"tracking": (
|
@@ -481,7 +487,7 @@ class _RestClient:
|
|
481
487
|
),
|
482
488
|
"metrics": (
|
483
489
|
"metrics.json",
|
484
|
-
metrics
|
490
|
+
pydantic_json_method(metrics)(exclude_none=True).encode(),
|
485
491
|
"application/json",
|
486
492
|
),
|
487
493
|
"file": (metadata_with_md5.name, file, "application/octet-stream"),
|
@@ -489,7 +495,7 @@ class _RestClient:
|
|
489
495
|
if search_customization is not None:
|
490
496
|
files["customization"] = (
|
491
497
|
"customization.json",
|
492
|
-
search_customization
|
498
|
+
pydantic_json_method(search_customization)(exclude_none=True).encode(),
|
493
499
|
"application/json",
|
494
500
|
)
|
495
501
|
additional_headers = {self.SEARCH_KEYS_HEADER_NAME: ",".join(self.search_keys_meaning_types(metadata))}
|
@@ -504,7 +510,7 @@ class _RestClient:
|
|
504
510
|
def check_uploaded_file_v2(self, trace_id: str, file_upload_id: str, metadata: FileMetadata) -> bool:
|
505
511
|
api_path = self.CHECK_UPLOADED_FILE_URL_FMT_V2.format(file_upload_id)
|
506
512
|
response = self._with_unauth_retry(
|
507
|
-
lambda: self._send_post_req(api_path, trace_id, metadata
|
513
|
+
lambda: self._send_post_req(api_path, trace_id, pydantic_json_method(metadata)(exclude_none=True))
|
508
514
|
)
|
509
515
|
return bool(response)
|
510
516
|
|
@@ -518,11 +524,15 @@ class _RestClient:
|
|
518
524
|
) -> SearchTaskResponse:
|
519
525
|
api_path = self.INITIAL_SEARCH_WITHOUT_UPLOAD_URI_FMT_V2.format(file_upload_id)
|
520
526
|
files = {
|
521
|
-
"metadata": (
|
522
|
-
|
527
|
+
"metadata": (
|
528
|
+
"metadata.json",
|
529
|
+
pydantic_json_method(metadata)(exclude_none=True).encode(),
|
530
|
+
"application/json",
|
531
|
+
),
|
532
|
+
"metrics": ("metrics.json", pydantic_json_method(metrics)(exclude_none=True).encode(), "application/json"),
|
523
533
|
}
|
524
534
|
if search_customization is not None:
|
525
|
-
files["customization"] = search_customization
|
535
|
+
files["customization"] = pydantic_json_method(search_customization)(exclude_none=True).encode()
|
526
536
|
additional_headers = {self.SEARCH_KEYS_HEADER_NAME: ",".join(self.search_keys_meaning_types(metadata))}
|
527
537
|
response = self._with_unauth_retry(
|
528
538
|
lambda: self._send_post_file_req_v2(
|
@@ -548,19 +558,19 @@ class _RestClient:
|
|
548
558
|
content = file.read()
|
549
559
|
md5_hash.update(content)
|
550
560
|
digest = md5_hash.hexdigest()
|
551
|
-
metadata_with_md5 = metadata
|
561
|
+
metadata_with_md5 = pydantic_copy_method(metadata)(update={"checksumMD5": digest})
|
552
562
|
|
553
563
|
# digest_sha256 = hashlib.sha256(
|
554
564
|
# pd.util.hash_pandas_object(pd.read_parquet(file_path, engine="fastparquet")).values
|
555
565
|
# ).hexdigest()
|
556
566
|
digest_sha256 = self.compute_file_digest(file_path)
|
557
|
-
metadata_with_md5 = metadata_with_md5
|
567
|
+
metadata_with_md5 = pydantic_copy_method(metadata_with_md5)(update={"digest": digest_sha256})
|
558
568
|
|
559
569
|
with open(file_path, "rb") as file:
|
560
570
|
files = {
|
561
571
|
"metadata": (
|
562
572
|
"metadata.json",
|
563
|
-
metadata_with_md5
|
573
|
+
pydantic_json_method(metadata_with_md5)(exclude_none=True).encode(),
|
564
574
|
"application/json",
|
565
575
|
),
|
566
576
|
"tracking": (
|
@@ -570,7 +580,7 @@ class _RestClient:
|
|
570
580
|
),
|
571
581
|
"metrics": (
|
572
582
|
"metrics.json",
|
573
|
-
metrics
|
583
|
+
pydantic_json_method(metrics)(exclude_none=True).encode(),
|
574
584
|
"application/json",
|
575
585
|
),
|
576
586
|
"file": (metadata_with_md5.name, file, "application/octet-stream"),
|
@@ -578,7 +588,7 @@ class _RestClient:
|
|
578
588
|
if search_customization is not None:
|
579
589
|
files["customization"] = (
|
580
590
|
"customization.json",
|
581
|
-
search_customization
|
591
|
+
pydantic_json_method(search_customization)(exclude_none=True).encode(),
|
582
592
|
"application/json",
|
583
593
|
)
|
584
594
|
|
@@ -602,11 +612,15 @@ class _RestClient:
|
|
602
612
|
) -> SearchTaskResponse:
|
603
613
|
api_path = self.VALIDATION_SEARCH_WITHOUT_UPLOAD_URI_FMT_V2.format(file_upload_id, initial_search_task_id)
|
604
614
|
files = {
|
605
|
-
"metadata": (
|
606
|
-
|
615
|
+
"metadata": (
|
616
|
+
"metadata.json",
|
617
|
+
pydantic_json_method(metadata)(exclude_none=True).encode(),
|
618
|
+
"application/json",
|
619
|
+
),
|
620
|
+
"metrics": ("metrics.json", pydantic_json_method(metrics)(exclude_none=True).encode(), "application/json"),
|
607
621
|
}
|
608
622
|
if search_customization is not None:
|
609
|
-
files["customization"] = search_customization
|
623
|
+
files["customization"] = pydantic_json_method(search_customization)(exclude_none=True).encode()
|
610
624
|
additional_headers = {self.SEARCH_KEYS_HEADER_NAME: ",".join(self.search_keys_meaning_types(metadata))}
|
611
625
|
response = self._with_unauth_retry(
|
612
626
|
lambda: self._send_post_file_req_v2(
|
@@ -670,7 +684,7 @@ class _RestClient:
|
|
670
684
|
"file": (metadata.name, file, "application/octet-stream"),
|
671
685
|
"metadata": (
|
672
686
|
"metadata.json",
|
673
|
-
metadata
|
687
|
+
pydantic_json_method(metadata)(exclude_none=True).encode(),
|
674
688
|
"application/json",
|
675
689
|
),
|
676
690
|
}
|
@@ -682,12 +696,12 @@ class _RestClient:
|
|
682
696
|
def get_search_file_metadata(self, search_task_id: str, trace_id: str) -> FileMetadata:
|
683
697
|
api_path = self.SEARCH_FILE_METADATA_URI_FMT_V2.format(search_task_id)
|
684
698
|
response = self._with_unauth_retry(lambda: self._send_get_req(api_path, trace_id))
|
685
|
-
return FileMetadata
|
699
|
+
return pydantic_parse_method(FileMetadata)(response)
|
686
700
|
|
687
701
|
def get_provider_search_metadata_v3(self, provider_search_task_id: str, trace_id: str) -> ProviderTaskMetadataV2:
|
688
702
|
api_path = self.SEARCH_TASK_METADATA_FMT_V3.format(provider_search_task_id)
|
689
703
|
response = self._with_unauth_retry(lambda: self._send_get_req(api_path, trace_id))
|
690
|
-
return ProviderTaskMetadataV2
|
704
|
+
return pydantic_parse_method(ProviderTaskMetadataV2)(response)
|
691
705
|
|
692
706
|
def get_current_transform_usage(self, trace_id) -> TransformUsage:
|
693
707
|
track_metrics = get_track_metrics(self.client_ip, self.client_visitorid)
|
@@ -706,7 +720,7 @@ class _RestClient:
|
|
706
720
|
lambda: self._send_post_req(
|
707
721
|
api_path,
|
708
722
|
trace_id=None,
|
709
|
-
json_data=log_event
|
723
|
+
json_data=pydantic_dump_method(log_event)(exclude_none=True),
|
710
724
|
content_type="application/json",
|
711
725
|
result_format="text",
|
712
726
|
silent=True,
|
@@ -723,7 +737,7 @@ class _RestClient:
|
|
723
737
|
try:
|
724
738
|
requests.post(
|
725
739
|
url=urljoin(_RestClient.PROD_BACKEND_URL, api_path),
|
726
|
-
json=log_event
|
740
|
+
json=pydantic_dump_method(log_event)(exclude_none=True),
|
727
741
|
headers=_RestClient._get_base_headers(content_type="application/json"),
|
728
742
|
)
|
729
743
|
except Exception:
|
@@ -1,10 +1,10 @@
|
|
1
|
-
upgini/__about__.py,sha256=
|
1
|
+
upgini/__about__.py,sha256=ecLPy8e5nmkHwHQrZPVIZD4Et6AoZCfYC38tO5V5-UI,25
|
2
2
|
upgini/__init__.py,sha256=LXSfTNU0HnlOkE69VCxkgIKDhWP-JFo_eBQ71OxTr5Y,261
|
3
3
|
upgini/ads.py,sha256=nvuRxRx5MHDMgPr9SiU-fsqRdFaBv8p4_v1oqiysKpc,2714
|
4
4
|
upgini/dataset.py,sha256=fRtqSkXNONLnPe6cCL967GMt349FTIpXzy_u8LUKncw,35354
|
5
5
|
upgini/errors.py,sha256=2b_Wbo0OYhLUbrZqdLIx5jBnAsiD1Mcenh-VjR4HCTw,950
|
6
6
|
upgini/features_enricher.py,sha256=G0qbRPdlWe9p6cwYF3khP99-0kgAO8N0A2sfQxSLgmM,213446
|
7
|
-
upgini/http.py,sha256=
|
7
|
+
upgini/http.py,sha256=6Qcepv0tDC72mBBJxYHnA2xqw6QwFaKrXN8o4vju8Es,44372
|
8
8
|
upgini/metadata.py,sha256=zt_9k0iQbWXuiRZcel4ORNPdQKt6Ou69ucZD_E1Q46o,12341
|
9
9
|
upgini/metrics.py,sha256=3cip0_L6-OFew74KsRwzxJDU6UFq05h2v7IsyHLcMRc,43164
|
10
10
|
upgini/search_task.py,sha256=Q5HjBpLIB3OCxAD1zNv5yQ3ZNJx696WCK_-H35_y7Rs,17912
|
@@ -16,11 +16,11 @@ upgini/autofe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
upgini/autofe/all_operators.py,sha256=rdjF5eaE4bC6Q4eu_el5Z7ekYt8DjOFermz2bePPbUc,333
|
17
17
|
upgini/autofe/binary.py,sha256=oOEECc4nRzZN2tYaiqx8F2XHnfWpk1bVvb7ZkZJ0lO8,7709
|
18
18
|
upgini/autofe/date.py,sha256=MM1S-6imNSzCDOhbNnmsc_bwSqUWBcS8vWAdHF8j1kY,11134
|
19
|
-
upgini/autofe/feature.py,sha256=
|
19
|
+
upgini/autofe/feature.py,sha256=aivkeVkJYzaT65Ug8dnd6__vr9QwcXxXQiNummjFwkE,15435
|
20
20
|
upgini/autofe/groupby.py,sha256=IYmQV9uoCdRcpkeWZj_kI3ObzoNCNx3ff3h8sTL01tk,3603
|
21
21
|
upgini/autofe/operator.py,sha256=EOffJw6vKXpEh5yymqb1RFNJPxGxmnHdFRo9dB5SCFo,4969
|
22
22
|
upgini/autofe/unary.py,sha256=Sx11IoHRh5nwyALzjgG9GQOrVNIs8NZ1JzunAJuN66A,5731
|
23
|
-
upgini/autofe/utils.py,sha256=
|
23
|
+
upgini/autofe/utils.py,sha256=dYrtyAM8Vcc_R8u4dNo54IsGrHKagTHDJTKhGho0bRg,2967
|
24
24
|
upgini/autofe/vector.py,sha256=jHs0nNTOaHspYUlxW7fjQepk4cvr_JDQ65L1OCiVsds,1360
|
25
25
|
upgini/autofe/timeseries/__init__.py,sha256=PGwwDAMwvkXl3el12tXVEmZUgDUvlmIPlXtROm6bD18,738
|
26
26
|
upgini/autofe/timeseries/base.py,sha256=rWJqRuFAzTZEsUdWG5s1Vhif9zzRRmalASXvarufRxI,3610
|
@@ -70,7 +70,7 @@ upgini/utils/target_utils.py,sha256=LRN840dzx78-wg7ftdxAkp2c1eu8-JDvkACiRThm4HE,
|
|
70
70
|
upgini/utils/track_info.py,sha256=G5Lu1xxakg2_TQjKZk4b5SvrHsATTXNVV3NbvWtT8k8,5663
|
71
71
|
upgini/utils/ts_utils.py,sha256=26vhC0pN7vLXK6R09EEkMK3Lwb9IVPH7LRdqFIQ3kPs,1383
|
72
72
|
upgini/utils/warning_counter.py,sha256=-GRY8EUggEBKODPSuXAkHn9KnEQwAORC0mmz_tim-PM,254
|
73
|
-
upgini-1.2.
|
74
|
-
upgini-1.2.
|
75
|
-
upgini-1.2.
|
76
|
-
upgini-1.2.
|
73
|
+
upgini-1.2.86a1.dist-info/METADATA,sha256=NFKCl8fGXfDQAKjDwAKG-Q6xEpvQ9mRld6WvqhUSZcU,49164
|
74
|
+
upgini-1.2.86a1.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
75
|
+
upgini-1.2.86a1.dist-info/licenses/LICENSE,sha256=5RRzgvdJUu3BUDfv4bzVU6FqKgwHlIay63pPCSmSgzw,1514
|
76
|
+
upgini-1.2.86a1.dist-info/RECORD,,
|
File without changes
|