sdv 1.36.4.dev0__tar.gz → 1.37.1.dev0__tar.gz
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.
- {sdv-1.36.4.dev0/sdv.egg-info → sdv-1.37.1.dev0}/PKG-INFO +1 -1
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/pyproject.toml +1 -1
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/__init__.py +1 -1
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/_utils.py +10 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/_utils.py +28 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/datasets/demo.py +111 -3
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/multi_table/base.py +4 -13
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/base.py +4 -13
- sdv-1.37.1.dev0/sdv/utils/__init__.py +15 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/utils/utils.py +15 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0/sdv.egg-info}/PKG-INFO +1 -1
- sdv-1.36.4.dev0/sdv/utils/__init__.py +0 -5
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/LICENSE +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/README.md +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/_errors.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/base.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/fixed_combinations.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/fixed_increments.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/inequality.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/one_hot_encoding.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/programmable_constraint.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/cag/range.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/constraints/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/constraints/base.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/constraints/errors.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/constraints/tabular.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/constraints/utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/data_processing/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/data_processing/data_processor.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/data_processing/datetime_formatter.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/data_processing/errors.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/data_processing/numerical_formatter.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/data_processing/utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/datasets/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/datasets/local.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/errors.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/evaluation/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/evaluation/_utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/evaluation/multi_table.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/evaluation/single_table.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/io/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/io/local/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/io/local/local.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/lite/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/lite/single_table.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/logging/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/logging/logger.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/logging/sdv_logger_config.yml +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/logging/utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/errors.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/metadata.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/metadata_upgrader.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/multi_table.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/single_table.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metadata/visualization.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metrics/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metrics/demos.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metrics/relational.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metrics/tabular.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/metrics/timeseries.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/multi_table/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/multi_table/dayz.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/multi_table/hma.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/multi_table/utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/sampling/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/sampling/hierarchical_sampler.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/sampling/independent_sampler.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/sampling/tabular.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/sequential/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/sequential/par.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/copulagan.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/copulas.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/ctgan.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/dayz.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/single_table/utils.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/utils/mixins.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/utils/poc.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv/version/__init__.py +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv.egg-info/SOURCES.txt +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv.egg-info/dependency_links.txt +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv.egg-info/entry_points.txt +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv.egg-info/requires.txt +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/sdv.egg-info/top_level.txt +0 -0
- {sdv-1.36.4.dev0 → sdv-1.37.1.dev0}/setup.cfg +0 -0
|
@@ -149,7 +149,7 @@ namespaces = false
|
|
|
149
149
|
version = {attr = 'sdv.__version__'}
|
|
150
150
|
|
|
151
151
|
[tool.bumpversion]
|
|
152
|
-
current_version = "1.
|
|
152
|
+
current_version = "1.37.1.dev0"
|
|
153
153
|
parse = '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<candidate>\d+))?'
|
|
154
154
|
serialize = [
|
|
155
155
|
'{major}.{minor}.{patch}.{release}{candidate}',
|
|
@@ -507,6 +507,16 @@ def warn_load_deprecated():
|
|
|
507
507
|
)
|
|
508
508
|
|
|
509
509
|
|
|
510
|
+
def warn_set_constraints_deprecated():
|
|
511
|
+
"""Warn that the `set_constraints` method on synthesizer is deprecated."""
|
|
512
|
+
deprecation_msg = (
|
|
513
|
+
'Warning: The `set_constraints` method is deprecated. '
|
|
514
|
+
'Please use the `load_constraints` utility function to load constraints from a file '
|
|
515
|
+
'and add them to the synthesizer with the `add_constraints` method.'
|
|
516
|
+
)
|
|
517
|
+
warnings.warn(deprecation_msg, FutureWarning)
|
|
518
|
+
|
|
519
|
+
|
|
510
520
|
def _validate_correct_synthesizer_loading(synthesizer, cls):
|
|
511
521
|
"""Validate that the loaded synthesizer is of the correct type."""
|
|
512
522
|
synthesizer_name = synthesizer.__class__.__name__
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import importlib
|
|
2
|
+
import json
|
|
2
3
|
import re
|
|
4
|
+
import traceback
|
|
3
5
|
import warnings
|
|
4
6
|
|
|
5
7
|
import numpy as np
|
|
@@ -269,3 +271,29 @@ def load_constraint_from_dict(constraint_dict):
|
|
|
269
271
|
raise ValueError(f"Unknown `constraint_class` '{class_name}'.")
|
|
270
272
|
|
|
271
273
|
return constraint_class.load_constraint_from_dict(parameters=parameters)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _load_constraints_from_file(filepath):
|
|
277
|
+
"""Load constraints from a file (JSON).
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
filepath (str):
|
|
281
|
+
The string path to the file containing the constraints to load.
|
|
282
|
+
|
|
283
|
+
Returns:
|
|
284
|
+
list[BaseConstraint]:
|
|
285
|
+
A list of constraint objects.
|
|
286
|
+
"""
|
|
287
|
+
with open(filepath, 'r') as f:
|
|
288
|
+
constraints_json = json.load(f)
|
|
289
|
+
|
|
290
|
+
constraint_list = []
|
|
291
|
+
for constraint_dict in constraints_json:
|
|
292
|
+
try:
|
|
293
|
+
constraint_list.append(load_constraint_from_dict(constraint_dict))
|
|
294
|
+
except Exception as e:
|
|
295
|
+
warnings.warn(
|
|
296
|
+
f'Could not load constraint ({constraint_dict}):\n'
|
|
297
|
+
f' {traceback.format_exception_only(type(e), e)[0]}'
|
|
298
|
+
)
|
|
299
|
+
return constraint_list
|
|
@@ -73,6 +73,27 @@ def _get_data_from_bucket(object_key, bucket, client):
|
|
|
73
73
|
return response['Body'].read()
|
|
74
74
|
|
|
75
75
|
|
|
76
|
+
def _save_data_from_bucket(object_key, bucket, client, output_filepath):
|
|
77
|
+
"""Save a file from an S3 bucket to the output_file.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
object_key (str):
|
|
81
|
+
The key of the object to get.
|
|
82
|
+
bucket (str):
|
|
83
|
+
The name of the bucket to get the object from.
|
|
84
|
+
client (botocore.client.S3):
|
|
85
|
+
S3 client.
|
|
86
|
+
output_filepath (str):
|
|
87
|
+
The location to save the file to disk.
|
|
88
|
+
"""
|
|
89
|
+
parent = os.path.dirname(str(output_filepath))
|
|
90
|
+
if parent:
|
|
91
|
+
os.makedirs(parent, exist_ok=True)
|
|
92
|
+
|
|
93
|
+
response = client.download_file(Bucket=bucket, Key=object_key, Filename=output_filepath)
|
|
94
|
+
return response['Body'].read()
|
|
95
|
+
|
|
96
|
+
|
|
76
97
|
def _get_dataset_name_from_prefix(prefix):
|
|
77
98
|
return prefix.split('/')[1]
|
|
78
99
|
|
|
@@ -211,7 +232,7 @@ def _get_first_v1_metadata_bytes(contents, dataset_prefix, bucket, client):
|
|
|
211
232
|
)
|
|
212
233
|
|
|
213
234
|
|
|
214
|
-
def
|
|
235
|
+
def _download_file_error_message(
|
|
215
236
|
modality,
|
|
216
237
|
dataset_name,
|
|
217
238
|
output_filepath=None,
|
|
@@ -666,7 +687,7 @@ def _save_document(text, output_filepath, filename, dataset_name):
|
|
|
666
687
|
LOGGER.info(f'Error saving {filename} for dataset {dataset_name}.')
|
|
667
688
|
|
|
668
689
|
|
|
669
|
-
@handle_aws_client_errors(
|
|
690
|
+
@handle_aws_client_errors(_download_file_error_message)
|
|
670
691
|
def _get_text_file_content(
|
|
671
692
|
modality, dataset_name, filename, output_filepath=None, bucket=PUBLIC_BUCKET, credentials=None
|
|
672
693
|
):
|
|
@@ -717,7 +738,53 @@ def _get_text_file_content(
|
|
|
717
738
|
return text
|
|
718
739
|
|
|
719
740
|
|
|
720
|
-
@handle_aws_client_errors(
|
|
741
|
+
@handle_aws_client_errors(_download_file_error_message)
|
|
742
|
+
def _save_file_content(
|
|
743
|
+
modality, dataset_name, filename, output_filepath, bucket=PUBLIC_BUCKET, credentials=None
|
|
744
|
+
):
|
|
745
|
+
"""Fetch text file content under the dataset prefix.
|
|
746
|
+
|
|
747
|
+
Args:
|
|
748
|
+
modality (str):
|
|
749
|
+
The modality of the dataset: ``'single_table'``, ``'multi_table'``, ``'sequential'``.
|
|
750
|
+
dataset_name (str):
|
|
751
|
+
The name of the dataset.
|
|
752
|
+
filename (str):
|
|
753
|
+
The filename to fetch (``'README.txt'`` or ``'SOURCE.txt'``).
|
|
754
|
+
output_filepath (str):
|
|
755
|
+
Save the file contents at this path.
|
|
756
|
+
bucket (str):
|
|
757
|
+
The name of the bucket to download from. Only 'sdv-datasets-public' is supported in
|
|
758
|
+
SDV Community. SDV Enterprise is required for other buckets.
|
|
759
|
+
credentials (dict):
|
|
760
|
+
Dictionary containing DataCebo license key and username. It takes the form:
|
|
761
|
+
{
|
|
762
|
+
'username': 'example@datacebo.com',
|
|
763
|
+
'license_key': '<MY_LICENSE_KEY>'
|
|
764
|
+
}
|
|
765
|
+
"""
|
|
766
|
+
_validate_modalities(modality)
|
|
767
|
+
if os.path.exists(str(output_filepath)):
|
|
768
|
+
raise ValueError(
|
|
769
|
+
f"A file named '{output_filepath}' already exists. Please specify a different filepath."
|
|
770
|
+
)
|
|
771
|
+
|
|
772
|
+
dataset_prefix = f'{modality}/{dataset_name}/'
|
|
773
|
+
s3_client = _create_s3_client(bucket=bucket, credentials=credentials)
|
|
774
|
+
contents = _list_objects(dataset_prefix, bucket=bucket, client=s3_client)
|
|
775
|
+
key = _find_text_key(contents, dataset_prefix, filename)
|
|
776
|
+
if not key:
|
|
777
|
+
_raise_warnings(filename, output_filepath)
|
|
778
|
+
return None
|
|
779
|
+
|
|
780
|
+
try:
|
|
781
|
+
_save_data_from_bucket(
|
|
782
|
+
key, bucket=bucket, client=s3_client, output_filepath=output_filepath
|
|
783
|
+
)
|
|
784
|
+
except Exception:
|
|
785
|
+
LOGGER.info(f'Error saving {filename} for dataset {dataset_name}.')
|
|
786
|
+
|
|
787
|
+
|
|
721
788
|
def get_source(
|
|
722
789
|
modality, dataset_name, output_filepath=None, s3_bucket_name=PUBLIC_BUCKET, credentials=None
|
|
723
790
|
):
|
|
@@ -788,3 +855,44 @@ def get_readme(
|
|
|
788
855
|
bucket=s3_bucket_name,
|
|
789
856
|
credentials=credentials,
|
|
790
857
|
)
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
def save_resource(
|
|
861
|
+
modality,
|
|
862
|
+
dataset_name,
|
|
863
|
+
resource_filename,
|
|
864
|
+
output_filepath,
|
|
865
|
+
s3_bucket_name='sdv-datasets-public',
|
|
866
|
+
credentials=None,
|
|
867
|
+
):
|
|
868
|
+
"""Save the resource to disk.
|
|
869
|
+
|
|
870
|
+
Args:
|
|
871
|
+
modality (str):
|
|
872
|
+
The modality of the dataset: ``'single_table'``, ``'multi_table'``, ``'sequential'``.
|
|
873
|
+
dataset_name (str):
|
|
874
|
+
The name of the dataset to get the README for.
|
|
875
|
+
resource_filename (str):
|
|
876
|
+
The name of the file to download from S3.
|
|
877
|
+
output_filepath (str or None):
|
|
878
|
+
Optional path where to save the file.
|
|
879
|
+
s3_bucket_name (str, optional):
|
|
880
|
+
The name of the bucket to download from. Only 'sdv-datasets-public' is supported in
|
|
881
|
+
SDV Community. SDV Enterprise is required for other buckets. Defaults to
|
|
882
|
+
'sdv-datasets-public'.
|
|
883
|
+
credentials (dict, optional):
|
|
884
|
+
Dictionary containing DataCebo license key and username. It takes the form:
|
|
885
|
+
{
|
|
886
|
+
'username': 'example@datacebo.com',
|
|
887
|
+
'license_key': '<MY_LICENSE_KEY>'
|
|
888
|
+
}
|
|
889
|
+
Defaults to None.
|
|
890
|
+
"""
|
|
891
|
+
_save_file_content(
|
|
892
|
+
modality=modality,
|
|
893
|
+
dataset_name=dataset_name,
|
|
894
|
+
filename=resource_filename,
|
|
895
|
+
output_filepath=output_filepath,
|
|
896
|
+
bucket=s3_bucket_name,
|
|
897
|
+
credentials=credentials,
|
|
898
|
+
)
|
|
@@ -22,13 +22,14 @@ from sdv._utils import (
|
|
|
22
22
|
check_synthesizer_version,
|
|
23
23
|
generate_synthesizer_id,
|
|
24
24
|
warn_load_deprecated,
|
|
25
|
+
warn_set_constraints_deprecated,
|
|
25
26
|
)
|
|
26
27
|
from sdv.cag._errors import ConstraintNotMetError
|
|
27
28
|
from sdv.cag._utils import (
|
|
28
29
|
_convert_to_snake_case,
|
|
29
30
|
_get_invalid_rows,
|
|
31
|
+
_load_constraints_from_file,
|
|
30
32
|
_validate_constraints,
|
|
31
|
-
load_constraint_from_dict,
|
|
32
33
|
)
|
|
33
34
|
from sdv.cag.programmable_constraint import ProgrammableConstraint, ProgrammableConstraintHarness
|
|
34
35
|
from sdv.errors import (
|
|
@@ -328,18 +329,8 @@ class BaseMultiTableSynthesizer:
|
|
|
328
329
|
'Cannot `set_constraints` since constraints have already been applied.'
|
|
329
330
|
)
|
|
330
331
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
constraint_list = []
|
|
335
|
-
for constraint_dict in constraints_json:
|
|
336
|
-
try:
|
|
337
|
-
constraint_list.append(load_constraint_from_dict(constraint_dict))
|
|
338
|
-
except Exception as e:
|
|
339
|
-
warnings.warn(
|
|
340
|
-
f'Could not load constraint ({constraint_dict}):\n'
|
|
341
|
-
f' {traceback.format_exception_only(type(e), e)[0]}'
|
|
342
|
-
)
|
|
332
|
+
warn_set_constraints_deprecated()
|
|
333
|
+
constraint_list = _load_constraints_from_file(filepath)
|
|
343
334
|
|
|
344
335
|
for constraint in constraint_list:
|
|
345
336
|
try:
|
|
@@ -32,13 +32,14 @@ from sdv._utils import (
|
|
|
32
32
|
check_synthesizer_version,
|
|
33
33
|
generate_synthesizer_id,
|
|
34
34
|
warn_load_deprecated,
|
|
35
|
+
warn_set_constraints_deprecated,
|
|
35
36
|
)
|
|
36
37
|
from sdv.cag._errors import ConstraintNotMetError
|
|
37
38
|
from sdv.cag._utils import (
|
|
38
39
|
_convert_to_snake_case,
|
|
39
40
|
_get_invalid_rows,
|
|
41
|
+
_load_constraints_from_file,
|
|
40
42
|
_validate_constraints_single_table,
|
|
41
|
-
load_constraint_from_dict,
|
|
42
43
|
)
|
|
43
44
|
from sdv.cag.programmable_constraint import ProgrammableConstraint, ProgrammableConstraintHarness
|
|
44
45
|
from sdv.data_processing.data_processor import DataProcessor
|
|
@@ -552,18 +553,8 @@ class BaseSynthesizer:
|
|
|
552
553
|
'Cannot `set_constraints` since constraints have already been applied.'
|
|
553
554
|
)
|
|
554
555
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
constraint_list = []
|
|
559
|
-
for constraint_dict in constraints_json:
|
|
560
|
-
try:
|
|
561
|
-
constraint_list.append(load_constraint_from_dict(constraint_dict))
|
|
562
|
-
except Exception as e:
|
|
563
|
-
warnings.warn(
|
|
564
|
-
f'Could not load constraint ({constraint_dict}):\n'
|
|
565
|
-
f' {traceback.format_exception_only(type(e), e)[0]}'
|
|
566
|
-
)
|
|
556
|
+
warn_set_constraints_deprecated()
|
|
557
|
+
constraint_list = _load_constraints_from_file(filepath)
|
|
567
558
|
|
|
568
559
|
for constraint in constraint_list:
|
|
569
560
|
try:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Utils module."""
|
|
2
|
+
|
|
3
|
+
from sdv.utils.utils import (
|
|
4
|
+
drop_unknown_references,
|
|
5
|
+
get_random_sequence_subset,
|
|
6
|
+
load_synthesizer,
|
|
7
|
+
load_constraints,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
__all__ = (
|
|
11
|
+
'drop_unknown_references',
|
|
12
|
+
'get_random_sequence_subset',
|
|
13
|
+
'load_synthesizer',
|
|
14
|
+
'load_constraints',
|
|
15
|
+
)
|
|
@@ -15,6 +15,7 @@ from sdv._utils import (
|
|
|
15
15
|
check_synthesizer_version,
|
|
16
16
|
generate_synthesizer_id,
|
|
17
17
|
)
|
|
18
|
+
from sdv.cag._utils import _load_constraints_from_file
|
|
18
19
|
from sdv.errors import InvalidDataError, SamplingError, SynthesizerInputError
|
|
19
20
|
from sdv.logging import get_sdv_logger
|
|
20
21
|
from sdv.metadata.metadata import Metadata
|
|
@@ -198,3 +199,17 @@ def load_synthesizer(filepath):
|
|
|
198
199
|
})
|
|
199
200
|
|
|
200
201
|
return synthesizer
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def load_constraints(filepath):
|
|
205
|
+
"""Load constraints from a file (JSON).
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
filepath (str):
|
|
209
|
+
The string path to the file containing the constraints to load.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
list[BaseConstraint]:
|
|
213
|
+
A list of constraint objects.
|
|
214
|
+
"""
|
|
215
|
+
return _load_constraints_from_file(filepath)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|