mostlyai 4.7.2__tar.gz → 4.7.4__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.
Files changed (86) hide show
  1. {mostlyai-4.7.2 → mostlyai-4.7.4}/PKG-INFO +1 -1
  2. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/__init__.py +1 -1
  3. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/pull_utils.py +2 -2
  4. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/api.py +44 -24
  5. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/generators.py +1 -1
  6. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/synthetic_datasets.py +1 -2
  7. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/domain.py +4 -4
  8. {mostlyai-4.7.2 → mostlyai-4.7.4}/pyproject.toml +1 -1
  9. {mostlyai-4.7.2 → mostlyai-4.7.4}/.gitignore +0 -0
  10. {mostlyai-4.7.2 → mostlyai-4.7.4}/LICENSE +0 -0
  11. {mostlyai-4.7.2 → mostlyai-4.7.4}/README.md +0 -0
  12. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/__init__.py +0 -0
  13. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/auto_detect.py +0 -0
  14. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/base.py +0 -0
  15. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/context.py +0 -0
  16. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/conversions.py +0 -0
  17. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/__init__.py +0 -0
  18. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/base.py +0 -0
  19. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  20. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/databricks.py +0 -0
  21. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/hive.py +0 -0
  22. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/mssql.py +0 -0
  23. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/mysql.py +0 -0
  24. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/oracle.py +0 -0
  25. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  26. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  27. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  28. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  29. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/dtype.py +0 -0
  30. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/exceptions.py +0 -0
  31. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/__init__.py +0 -0
  32. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/base.py +0 -0
  33. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  34. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  35. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  36. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  37. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  38. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  39. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  40. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  41. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  42. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/table/json.py +0 -0
  43. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  44. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/file/utils.py +0 -0
  45. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/language_model.py +0 -0
  46. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  47. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/non_context.py +0 -0
  48. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/progress_callback.py +0 -0
  49. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/pull.py +0 -0
  50. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/pull_context.py +0 -0
  51. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/push.py +0 -0
  52. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/util/__init__.py +0 -0
  53. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/util/common.py +0 -0
  54. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  55. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/__init__.py +0 -0
  56. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/cli.py +0 -0
  57. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/connectors.py +0 -0
  58. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  59. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/jobs.py +0 -0
  60. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/migration.py +0 -0
  61. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/plan.py +0 -0
  62. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  63. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  64. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  65. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  66. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  67. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
  68. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  69. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  70. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  71. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  72. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  73. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/generators.py +0 -0
  74. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/progress.py +0 -0
  75. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/routes.py +0 -0
  76. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/server.py +0 -0
  77. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/storage.py +0 -0
  78. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  79. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/__init__.py +0 -0
  80. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/_base_utils.py +0 -0
  81. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  82. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/_utils.py +0 -0
  83. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/base.py +0 -0
  84. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/connectors.py +0 -0
  85. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/client/exceptions.py +0 -0
  86. {mostlyai-4.7.2 → mostlyai-4.7.4}/mostlyai/sdk/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mostlyai
3
- Version: 4.7.2
3
+ Version: 4.7.4
4
4
  Summary: Synthetic Data SDK
5
5
  Project-URL: homepage, https://app.mostly.ai/
6
6
  Project-URL: repository, https://github.com/mostly-ai/mostlyai
@@ -15,4 +15,4 @@
15
15
  from mostlyai.sdk.client.api import MostlyAI
16
16
 
17
17
  __all__ = ["MostlyAI"]
18
- __version__ = "4.7.2" # Do not set this manually. Use poetry version [params].
18
+ __version__ = "4.7.4" # Do not set this manually. Use poetry version [params].
@@ -535,7 +535,7 @@ def fetch_context_tables(
535
535
  schema=schema,
536
536
  table_name=sibling_table,
537
537
  fetch_dir=fetch_dir,
538
- deduplicate_pks=False, # allow duplicate PKs in cross table context
538
+ deduplicate_pks=True, # drop duplicate PKs in cross table context
539
539
  where={context_key.column: pks},
540
540
  sample_fraction=None,
541
541
  key_fraction_df=None,
@@ -585,7 +585,7 @@ def fetch_target_table(
585
585
  schema=schema,
586
586
  table_name=tgt,
587
587
  fetch_dir=fetch_dir,
588
- deduplicate_pks=False, # allow duplicate PKs in target table
588
+ deduplicate_pks=True, # drop duplicate PKs in target table
589
589
  where=where,
590
590
  key_fraction_df=key_fraction_df,
591
591
  sample_fraction=sample_fraction,
@@ -241,6 +241,12 @@ class MostlyAI(_MostlyBaseClient):
241
241
  """
242
242
  Create a connector and optionally validate the connection before saving.
243
243
 
244
+ There are 3 access types for a connector (which are independent of the connector type):
245
+
246
+ - `READ_PROTECTED`: The connector is restricted to being used solely as a source for training a generator. Direct data access is not permitted, only schema access via `c.locations(prefix)` and `c.schema(location)` is available.
247
+ - `READ_DATA`: This connector allows full read access. It can also be used as a source for training a generator.
248
+ - `WRITE_DATA`: This connector allows full read and write access. It can be also used as a source for training a generator, as well as a destination for delivering a synthetic dataset.
249
+
244
250
  Args:
245
251
  config (ConnectorConfig | dict[str, Any]): Configuration for the connector. Can be either a ConnectorConfig object or an equivalent dictionary.
246
252
  test_connection (bool | None): Whether to validate the connection before saving. Default is True.
@@ -254,6 +260,7 @@ class MostlyAI(_MostlyBaseClient):
254
260
  mostly = MostlyAI()
255
261
  c = mostly.connect(
256
262
  config={
263
+ 'access_type': 'READ_PROTECTED', # or 'READ_DATA' or 'WRITE_DATA'
257
264
  'type': 'S3_STORAGE',
258
265
  'config': {
259
266
  'accessKey': '...',
@@ -395,7 +402,9 @@ class MostlyAI(_MostlyBaseClient):
395
402
  progress_bar: bool = True,
396
403
  ) -> Generator:
397
404
  """
398
- Train a generator.
405
+ Create a generator resource. Once trained, it will include the model as well as optionally a model report.
406
+
407
+ Note: A generator is initially being configured. That training job can be either launched immediately or later. One can check progress via `g.training.progress()`. Once the job has finished, the generator is available for use.
399
408
 
400
409
  Args:
401
410
  config (GeneratorConfig | dict | None): The configuration parameters of the generator to be created. Either `config` or `data` must be provided.
@@ -591,7 +600,9 @@ class MostlyAI(_MostlyBaseClient):
591
600
  progress_bar: bool = True,
592
601
  ) -> SyntheticDataset:
593
602
  """
594
- Generate synthetic data.
603
+ Create a synthetic dataset resource. Once generated, it will include the data as well as optionally a data report.
604
+
605
+ Note: A synthetic dataset is initially being configured. That generation job can be either launched immediately or later. One can check progress via `sd.generation.progress()`. Once the job has finished, the synthetic dataset is available for download via `sd.data()`, and the reports are available via `sd.reports()`.
595
606
 
596
607
  Args:
597
608
  generator (Generator | str): The generator instance or its UUID.
@@ -672,46 +683,55 @@ class MostlyAI(_MostlyBaseClient):
672
683
  return_type: Literal["auto", "dict"] = "auto",
673
684
  ) -> pd.DataFrame | dict[str, pd.DataFrame]:
674
685
  """
675
- Probe a generator.
686
+ Probe a generator for a new synthetic dataset (synchronously).
676
687
 
677
688
  Args:
678
689
  generator (Generator | str): The generator instance or its UUID.
679
690
  size (int | dict[str, int] | None): Sample size(s) for the subject table(s). Default is 1, if no seed is provided.
680
- seed (Seed | dict[str, Seed] | None): Seed data for the subject table(s).
691
+ seed (Seed | dict[str, Seed] | None): Seed data for the subject table(s). Check generator details for possible value ranges.
681
692
  config (SyntheticProbeConfig | dict | None): Configuration for the probe.
682
- return_type (Literal["auto", "dict"]): Format of the return value. "auto" for pandas DataFrame if a single table, otherwise a dictionary. Default is "auto".
693
+ return_type (Literal["auto", "dict"]): The type of the return value. "dict" will always provide a dictionary of DataFrames. "auto" will return a single DataFrame for a single-table generator, and a dictionary of DataFrames for a multi-table generator. Default is "auto".
683
694
 
684
695
  Returns:
685
- pd.DataFrame | dict[str, pd.DataFrame]: The created synthetic probe.
696
+ pd.DataFrame | dict[str, pd.DataFrame]: The created synthetic probe. See return_type for the format of the return value.
686
697
 
687
698
  Example for probing a generator for 10 synthetic samples:
688
699
  ```python
689
700
  from mostlyai.sdk import MostlyAI
690
701
  mostly = MostlyAI()
691
- probe = mostly.probe(
692
- generator='INSERT_YOUR_GENERATOR_ID',
693
- size=10
694
- )
702
+ data = mostly.probe('INSERT_YOUR_GENERATOR_ID', size=10, return_type="dict")
695
703
  ```
696
704
 
697
- Example for conditional probing a generator for 10 synthetic samples:
705
+ Example for conditional probing based on a seed DataFrame:
698
706
  ```python
699
707
  import pandas as pd
700
708
  from mostlyai.sdk import MostlyAI
701
709
  mostly = MostlyAI()
702
- g = mostly.generators.get('INSERT_YOUR_GENERATOR_ID')
703
- print('columns:', [c.name for c in g.tables[0].columns])
704
- # columns: ['age', 'workclass', 'fnlwgt', ...]
705
- col = g.tables[0].columns[1]
706
- print(col.name, col.value_range.values)
707
- # workclass: ['Federal-gov', 'Local-gov', 'Never-worked', ...]
708
- mostly.probe(
709
- generator=g,
710
- seed=pd.DataFrame({
711
- 'age': [63, 45],
712
- 'sex': ['Female', 'Male'],
713
- 'workclass': ['Sales', 'Tech-support'],
714
- }),
710
+ seed = pd.DataFrame({'col1': ['x', 'y'], 'col2': [13, 74]})
711
+ data = mostly.probe('INSERT_YOUR_GENERATOR_ID', seed=seed, return_type="dict")
712
+ ```
713
+
714
+ Example for advanced probing configuration:
715
+ ```python
716
+ import pandas as pd
717
+ from mostlyai.sdk import MostlyAI
718
+ mostly = MostlyAI()
719
+ data = mostly.probe(
720
+ 'INSERT_YOUR_GENERATOR_ID',
721
+ config={
722
+ 'tables': [{
723
+ 'name': 'tbl1',
724
+ 'configuration': {
725
+ 'sample_size': 100,
726
+ 'sampling_temperature': 1.0,
727
+ 'sampling_top_p': 1.0,
728
+ 'rebalancing': {'column': 'country', 'probabilities': {'US': 0.5, 'CA', 0.3}},
729
+ 'imputation': {'columns': ['age']},
730
+ 'fairness': {'target_column': 'income', 'sensitive_columns': ['gender']},
731
+ }
732
+ }]
733
+ },
734
+ return_type="dict"
715
735
  )
716
736
  ```
717
737
  """
@@ -281,7 +281,7 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
281
281
  # Check if 'Content-Disposition' header is present
282
282
  if "Content-Disposition" in response.headers:
283
283
  content_disposition = response.headers["Content-Disposition"]
284
- filename = re.findall("filename=(.+)", content_disposition)[0]
284
+ filename = re.findall(r"filename(?:=|\*=UTF-8'')(.+)", content_disposition)[0]
285
285
  else:
286
286
  filename = f"generator-{generator_id[:8]}.zip"
287
287
  return content_bytes, filename
@@ -231,7 +231,7 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
231
231
  # Check if 'Content-Disposition' header is present
232
232
  if "Content-Disposition" in response.headers:
233
233
  content_disposition = response.headers["Content-Disposition"]
234
- filename = re.findall("filename=(.+)", content_disposition)[0]
234
+ filename = re.findall(r"filename(?:=|\*=UTF-8'')(.+)", content_disposition)[0]
235
235
  else:
236
236
  filename = f"synthetic-dataset-{synthetic_dataset_id[:8]}.zip"
237
237
  return content_bytes, filename
@@ -252,7 +252,6 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
252
252
  name for name in z.namelist() if name.startswith(f"{table}/") and name.endswith(".parquet")
253
253
  ]
254
254
  dfs[table] = pd.concat([pd.read_parquet(z.open(name)) for name in pqt_files], axis=0)
255
- dfs[table].name = table
256
255
  return dfs
257
256
 
258
257
  def _report(
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  # generated by datamodel-codegen:
16
- # timestamp: 2025-06-03T10:16:27+00:00
16
+ # timestamp: 2025-06-11T13:30:16+00:00
17
17
 
18
18
  from __future__ import annotations
19
19
 
@@ -2020,7 +2020,7 @@ class Connector(CustomBaseModel):
2020
2020
  Execute a read-only SQL query against the connector's data source.
2021
2021
 
2022
2022
  Queries can include statements like SELECT, SHOW, or DESCRIBE, but must not modify data or state.
2023
- For file-based connectors (S3_STORAGE, GOOGLE_CLOUD_STORAGE, AZURE_STORAGE) queries are executed using DuckDB.
2023
+ For file-based connectors (S3_STORAGE, GOOGLE_CLOUD_STORAGE, AZURE_STORAGE) queries are executed using DuckDB. Use connector-type-specific prefixes. See examples.
2024
2024
 
2025
2025
  Args:
2026
2026
  sql (str): The SQL query to execute.
@@ -3417,10 +3417,10 @@ class SyntheticDataset(CustomBaseModel):
3417
3417
  Download synthetic dataset and return as dictionary of pandas DataFrames.
3418
3418
 
3419
3419
  Args:
3420
- return_type (Literal["auto", "dict"]): The format of the returned data. Default is "auto".
3420
+ return_type (Literal["auto", "dict"]): The type of the return value. "dict" will always provide a dictionary of DataFrames. "auto" will return a single DataFrame for a single-table generator, and a dictionary of DataFrames for a multi-table generator. Default is "auto".
3421
3421
 
3422
3422
  Returns:
3423
- Union[pd.DataFrame, dict[str, pd.DataFrame]]: The synthetic dataset as a dictionary of pandas DataFrames.
3423
+ Union[pd.DataFrame, dict[str, pd.DataFrame]]: The synthetic dataset. See return_type for the format of the return value.
3424
3424
  """
3425
3425
  dfs = self.client._data(
3426
3426
  synthetic_dataset_id=self.id,
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.7.2"
3
+ version = "4.7.4"
4
4
  description = "Synthetic Data SDK"
5
5
  authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
6
6
  requires-python = ">=3.10,<3.14"
File without changes
File without changes
File without changes
File without changes