mostlyai 4.4.6__tar.gz → 4.4.8__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 (85) hide show
  1. {mostlyai-4.4.6 → mostlyai-4.4.8}/PKG-INFO +5 -5
  2. {mostlyai-4.4.6 → mostlyai-4.4.8}/README.md +1 -1
  3. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/bigquery.py +5 -6
  5. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/databricks.py +2 -5
  6. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/base.py +5 -0
  7. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/connectors.py +3 -0
  8. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/jobs.py +16 -13
  9. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_finalize_generation.py +15 -3
  10. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_train_model.py +1 -0
  11. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/domain.py +58 -16
  12. {mostlyai-4.4.6 → mostlyai-4.4.8}/pyproject.toml +4 -4
  13. {mostlyai-4.4.6 → mostlyai-4.4.8}/.gitignore +0 -0
  14. {mostlyai-4.4.6 → mostlyai-4.4.8}/LICENSE +0 -0
  15. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/__init__.py +0 -0
  16. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/auto_detect.py +0 -0
  17. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/base.py +0 -0
  18. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/context.py +0 -0
  19. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/conversions.py +0 -0
  20. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/__init__.py +0 -0
  21. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/base.py +0 -0
  22. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/hive.py +0 -0
  23. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/mssql.py +0 -0
  24. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/mysql.py +0 -0
  25. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/oracle.py +0 -0
  26. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  27. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  28. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  29. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  30. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/dtype.py +0 -0
  31. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/exceptions.py +0 -0
  32. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/__init__.py +0 -0
  33. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  34. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  35. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  36. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  37. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  38. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  39. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  40. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  41. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  42. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/table/json.py +0 -0
  43. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  44. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/file/utils.py +0 -0
  45. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/language_model.py +0 -0
  46. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  47. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/non_context.py +0 -0
  48. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/progress_callback.py +0 -0
  49. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/pull.py +0 -0
  50. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/pull_context.py +0 -0
  51. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/pull_utils.py +0 -0
  52. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/push.py +0 -0
  53. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/util/__init__.py +0 -0
  54. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/util/common.py +0 -0
  55. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  56. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/__init__.py +0 -0
  57. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/cli.py +0 -0
  58. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  59. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/plan.py +0 -0
  60. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  61. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  62. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  63. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  64. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  65. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  66. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  67. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  68. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  69. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/generators.py +0 -0
  70. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/progress.py +0 -0
  71. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/routes.py +0 -0
  72. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/server.py +0 -0
  73. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/storage.py +0 -0
  74. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  75. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/__init__.py +0 -0
  76. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/_base_utils.py +0 -0
  77. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  78. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/_utils.py +0 -0
  79. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/api.py +0 -0
  80. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/base.py +0 -0
  81. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/connectors.py +0 -0
  82. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/exceptions.py +0 -0
  83. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/generators.py +0 -0
  84. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/client/synthetic_datasets.py +0 -0
  85. {mostlyai-4.4.6 → mostlyai-4.4.8}/mostlyai/sdk/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mostlyai
3
- Version: 4.4.6
3
+ Version: 4.4.8
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
@@ -60,7 +60,7 @@ Requires-Dist: filelock>=3.16.1; extra == 'local'
60
60
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
61
61
  Requires-Dist: joblib>=1.2.0; extra == 'local'
62
62
  Requires-Dist: mostlyai-engine==1.1.11; extra == 'local'
63
- Requires-Dist: mostlyai-qa==1.5.12; extra == 'local'
63
+ Requires-Dist: mostlyai-qa==1.5.13; extra == 'local'
64
64
  Requires-Dist: networkx<4,>=3.0; extra == 'local'
65
65
  Requires-Dist: openpyxl>=3.1.5; extra == 'local'
66
66
  Requires-Dist: python-multipart>=0.0.20; extra == 'local'
@@ -83,7 +83,7 @@ Requires-Dist: filelock>=3.16.1; extra == 'local-cpu'
83
83
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local-cpu'
84
84
  Requires-Dist: joblib>=1.2.0; extra == 'local-cpu'
85
85
  Requires-Dist: mostlyai-engine[cpu]==1.1.11; extra == 'local-cpu'
86
- Requires-Dist: mostlyai-qa[cpu]==1.5.12; extra == 'local-cpu'
86
+ Requires-Dist: mostlyai-qa[cpu]==1.5.13; extra == 'local-cpu'
87
87
  Requires-Dist: networkx<4,>=3.0; extra == 'local-cpu'
88
88
  Requires-Dist: openpyxl>=3.1.5; extra == 'local-cpu'
89
89
  Requires-Dist: python-multipart>=0.0.20; extra == 'local-cpu'
@@ -106,7 +106,7 @@ Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
106
106
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
107
107
  Requires-Dist: joblib>=1.2.0; extra == 'local-gpu'
108
108
  Requires-Dist: mostlyai-engine[gpu]==1.1.11; extra == 'local-gpu'
109
- Requires-Dist: mostlyai-qa[gpu]==1.5.12; extra == 'local-gpu'
109
+ Requires-Dist: mostlyai-qa[gpu]==1.5.13; extra == 'local-gpu'
110
110
  Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
111
111
  Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
112
112
  Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
@@ -164,7 +164,7 @@ The SDK allows you to programmatically create, browse and manage 3 key resources
164
164
  | Live probe the generator on demand | `df = mostly.probe(g, config)` | [mostly.probe](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.probe) |
165
165
  | Connect to any data source within your org | `c = mostly.connect(config)` | [mostly.connect](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.connect) |
166
166
 
167
- <https://github.com/user-attachments/assets/d1613636-06e4-4147-bef7-25bb4699e8fc>
167
+ https://github.com/user-attachments/assets/9e233213-a259-455c-b8ed-d1f1548b492f
168
168
 
169
169
  ## Key Features
170
170
 
@@ -30,7 +30,7 @@ The SDK allows you to programmatically create, browse and manage 3 key resources
30
30
  | Live probe the generator on demand | `df = mostly.probe(g, config)` | [mostly.probe](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.probe) |
31
31
  | Connect to any data source within your org | `c = mostly.connect(config)` | [mostly.connect](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.connect) |
32
32
 
33
- <https://github.com/user-attachments/assets/d1613636-06e4-4147-bef7-25bb4699e8fc>
33
+ https://github.com/user-attachments/assets/9e233213-a259-455c-b8ed-d1f1548b492f
34
34
 
35
35
  ## Key Features
36
36
 
@@ -15,4 +15,4 @@
15
15
  from mostlyai.sdk.client.api import MostlyAI
16
16
 
17
17
  __all__ = ["MostlyAI"]
18
- __version__ = "4.4.6" # Do not set this manually. Use poetry version [params].
18
+ __version__ = "4.4.8" # Do not set this manually. Use poetry version [params].
@@ -73,12 +73,14 @@ class BigQueryContainer(SqlAlchemyContainer):
73
73
  return BigQueryTable
74
74
 
75
75
  def get_view_list(self) -> list[str]:
76
- return []
76
+ if not self.does_database_exist():
77
+ return []
78
+ return [table.table_id for table in self.client.list_tables(self.dbname) if table.table_type == "VIEW"]
77
79
 
78
80
  def get_table_list(self) -> list[str]:
79
81
  if not self.does_database_exist():
80
82
  return []
81
- return [table.table_id for table in self.client.list_tables(self.dbname) if table]
83
+ return [table.table_id for table in self.client.list_tables(self.dbname) if table.table_type == "TABLE"]
82
84
 
83
85
  def does_database_exist(self) -> bool:
84
86
  datasets = list(self.client.list_datasets())
@@ -103,7 +105,7 @@ class BigQueryContainer(SqlAlchemyContainer):
103
105
 
104
106
  def _valid_table_name(self, table_name: str) -> bool:
105
107
  """Validate table name."""
106
- return table_name in self.get_table_list()
108
+ return table_name in self.get_object_list()
107
109
 
108
110
  def _fetch_foreign_keys(self, table_name):
109
111
  """
@@ -172,9 +174,6 @@ class BigQueryContainer(SqlAlchemyContainer):
172
174
  _LOG.debug(f"Error while executing {query=}")
173
175
  return None
174
176
 
175
- def get_object_list(self):
176
- return self.get_table_list()
177
-
178
177
  def get_primary_key(self, table_name: str):
179
178
  return self._fetch_primary_key(table_name)
180
179
 
@@ -121,7 +121,7 @@ class DatabricksContainer(SqlAlchemyContainer):
121
121
  # so that we don't wait too long when the cluster is still starting and temporarily unavailable
122
122
  "_retry_delay_max": 10.0,
123
123
  "_retry_stop_after_attempts_count": 3,
124
- "use_inline_params": True,
124
+ "use_inline_params": "silent",
125
125
  }
126
126
 
127
127
  @classmethod
@@ -182,7 +182,7 @@ class DatabricksContainer(SqlAlchemyContainer):
182
182
 
183
183
  def _valid_table_name(self, table_name: str) -> bool:
184
184
  """Validate table name."""
185
- return table_name in self.get_table_list()
185
+ return table_name in self.get_object_list()
186
186
 
187
187
  def _fetch_foreign_keys(self, table_name: str) -> list[dict]:
188
188
  """
@@ -242,9 +242,6 @@ class DatabricksContainer(SqlAlchemyContainer):
242
242
  _LOG.debug(f"Error while executing {query=}")
243
243
  return None
244
244
 
245
- def get_object_list(self):
246
- return self.get_table_list()
247
-
248
245
  def get_primary_key(self, table_name: str):
249
246
  return self._fetch_primary_key(table_name)
250
247
 
@@ -513,6 +513,11 @@ class FileContainer(DataContainer):
513
513
  assert_read_only_sql(sql)
514
514
  try:
515
515
  with duckdb.connect(database=":memory:") as con:
516
+ con.execute("""
517
+ SET disabled_filesystems = 'LocalFileSystem';
518
+ SET allow_community_extensions = false;
519
+ SET lock_configuration = true;
520
+ """)
516
521
  self._init_duckdb(con)
517
522
  result = con.execute(sql).fetchdf()
518
523
 
@@ -28,6 +28,7 @@ from mostlyai.sdk.domain import (
28
28
  ConnectorReadDataConfig,
29
29
  ConnectorWriteDataConfig,
30
30
  ConnectorDeleteDataConfig,
31
+ ConnectorType,
31
32
  )
32
33
  from mostlyai.sdk._data.file.utils import make_data_table_from_container
33
34
 
@@ -61,6 +62,8 @@ def do_test_connection(connector: Connector) -> bool:
61
62
 
62
63
 
63
64
  def _data_table_from_connector_and_location(connector: Connector, location: str, is_output: bool):
65
+ if connector.type == ConnectorType.file_upload:
66
+ raise HTTPException(status_code=400, detail="Connector type FILE_UPLOAD is disallowed for this operation")
64
67
  container = create_container_from_connector(connector)
65
68
  meta = container.set_location(location)
66
69
  data_table = make_data_table_from_container(container, is_output=is_output)
@@ -34,6 +34,7 @@ from mostlyai.sdk._local.execution.step_encode_training_data import execute_step
34
34
  from mostlyai.sdk._local.execution.step_finalize_generation import (
35
35
  execute_step_finalize_generation,
36
36
  create_generation_schema,
37
+ update_total_rows,
37
38
  )
38
39
  from mostlyai.sdk._local.execution.step_generate_data import execute_step_generate_data
39
40
  from mostlyai.sdk._local.execution.step_generate_model_report_data import (
@@ -280,17 +281,18 @@ class Execution:
280
281
  if t.configuration.sample_seed_connector_id is not None
281
282
  ]
282
283
  connectors_dir = self._home_dir / "connectors"
283
- for connector_path in connectors_dir.iterdir():
284
- if not (connector_path.name in connector_ids and connector_path.is_dir()):
285
- continue
286
-
287
- try:
288
- connector = read_connector_from_json(connector_path)
289
- if connector.type == ConnectorType.file_upload:
290
- shutil.rmtree(connector_path)
291
- except Exception as e:
292
- _LOG.info(f"Failed to clear connector {connector_path}: {e}")
293
- pass
284
+ if connectors_dir.exists():
285
+ for connector_path in connectors_dir.iterdir():
286
+ if not (connector_path.name in connector_ids and connector_path.is_dir()):
287
+ continue
288
+
289
+ try:
290
+ connector = read_connector_from_json(connector_path)
291
+ if connector.type == ConnectorType.file_upload:
292
+ shutil.rmtree(connector_path)
293
+ except Exception as e:
294
+ _LOG.info(f"Failed to clear connector {connector_path}: {e}")
295
+ pass
294
296
 
295
297
  def run(self):
296
298
  # execute job
@@ -504,7 +506,7 @@ class Execution:
504
506
  step="finalize_generation",
505
507
  )
506
508
 
507
- execute_step_finalize_generation(
509
+ usages = execute_step_finalize_generation(
508
510
  schema=schema,
509
511
  is_probe=False,
510
512
  job_workspace_dir=self._job_workspace_dir,
@@ -514,6 +516,7 @@ class Execution:
514
516
  step_code=StepCode.finalize_generation,
515
517
  ),
516
518
  )
519
+ update_total_rows(self._synthetic_dataset, usages)
517
520
 
518
521
  def execute_deliver_data(self):
519
522
  schema = create_generation_schema(
@@ -544,7 +547,7 @@ class Execution:
544
547
  step="finalize_generation",
545
548
  )
546
549
  # step: FINALIZE_GENERATION
547
- execute_step_finalize_generation(
550
+ _ = execute_step_finalize_generation(
548
551
  schema=schema,
549
552
  is_probe=True,
550
553
  job_workspace_dir=self._job_workspace_dir,
@@ -30,7 +30,7 @@ from mostlyai.sdk._data.util.common import (
30
30
  NON_CONTEXT_COLUMN_INFIX,
31
31
  IS_NULL,
32
32
  )
33
- from mostlyai.sdk.domain import Generator
33
+ from mostlyai.sdk.domain import Generator, SyntheticDataset
34
34
 
35
35
  _LOG = logging.getLogger(__name__)
36
36
 
@@ -41,7 +41,11 @@ def execute_step_finalize_generation(
41
41
  is_probe: bool,
42
42
  job_workspace_dir: Path,
43
43
  update_progress: ProgressCallback | None = None,
44
- ) -> None:
44
+ ) -> dict[str, int]:
45
+ # get synthetic table usage
46
+ usages = dict()
47
+ for table_name, table in schema.tables.items():
48
+ usages.update({table_name: table.row_count})
45
49
  # short circuit for probing
46
50
  delivery_dir = job_workspace_dir / "FinalizedSyntheticData"
47
51
  if is_probe:
@@ -52,7 +56,7 @@ def execute_step_finalize_generation(
52
56
  delivery_dir=delivery_dir,
53
57
  export_csv=False,
54
58
  )
55
- return
59
+ return usages
56
60
 
57
61
  random_samples_dir = job_workspace_dir / "RandomSamples"
58
62
  zip_dir = job_workspace_dir / "ZIP"
@@ -94,6 +98,14 @@ def execute_step_finalize_generation(
94
98
  zip_data(delivery_dir=delivery_dir, format="csv", out_dir=zip_dir)
95
99
  progress.update(advance=1)
96
100
 
101
+ return usages
102
+
103
+
104
+ def update_total_rows(synthetic_dataset: SyntheticDataset, usages: dict[str, int]) -> None:
105
+ for table_name, total_rows in usages.items():
106
+ table = next(t for t in synthetic_dataset.tables if t.name == table_name)
107
+ table.total_rows = total_rows
108
+
97
109
 
98
110
  def format_datetime(df: pd.DataFrame) -> pd.DataFrame:
99
111
  for column in df.columns:
@@ -61,6 +61,7 @@ def execute_step_train_model(
61
61
  max_training_time=model_config.max_training_time,
62
62
  max_epochs=model_config.max_epochs,
63
63
  batch_size=model_config.batch_size,
64
+ gradient_accumulation_steps=model_config.gradient_accumulation_steps,
64
65
  max_sequence_window=max_sequence_window,
65
66
  enable_flexible_generation=model_config.enable_flexible_generation,
66
67
  differential_privacy=differential_privacy,
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  # generated by datamodel-codegen:
16
- # timestamp: 2025-04-01T14:13:05+00:00
16
+ # timestamp: 2025-04-02T12:04:56+00:00
17
17
 
18
18
  from __future__ import annotations
19
19
 
@@ -442,10 +442,7 @@ class ConnectorWriteDataConfig(CustomBaseModel):
442
442
  Configuration for writing data to a connector.
443
443
  """
444
444
 
445
- file: bytes = Field(
446
- ...,
447
- description="Binary Parquet file containing the data to write. If null, a delete data operation occurs.",
448
- )
445
+ file: bytes = Field(..., description="Binary Parquet file containing the data to write.")
449
446
  location: str = Field(
450
447
  ...,
451
448
  description="Specifies the target within the connector to which to write the data. The format of this parameter varies by connector type.",
@@ -1802,7 +1799,7 @@ class Connector(CustomBaseModel):
1802
1799
  List connector locations.
1803
1800
 
1804
1801
  List the available databases, schemas, tables, or folders for a connector.
1805
- For storage connectors, this returns list of folders and files at root, respectively at `prefix` level.
1802
+ For storage connectors, this returns list of buckets for empty prefix and otherwise the folders and files then within a path, specified via prefix.
1806
1803
  For DB connectors, this returns list of schemas (or databases for DBs without schema), respectively list of tables if `prefix` is provided.
1807
1804
 
1808
1805
  The formats of the locations are:
@@ -1826,25 +1823,42 @@ class Connector(CustomBaseModel):
1826
1823
  prefix (str): The prefix to filter the results by. Defaults to an empty string.
1827
1824
 
1828
1825
  Returns:
1829
- list[str]: A list of locations (schemas, databases, directories, etc.)."""
1826
+ list[str]: A list of locations (schemas, databases, directories, etc.).
1827
+
1828
+ Example:
1829
+ ```python
1830
+ c.locations() # list all schemas / databases for a DB connector; list all buckets for a storage connector
1831
+ c.locations('db_name') # list all tables in 'db_name' for a DB connector
1832
+ c.locations('s3://my_bucket') # list all objects in 'my_bucket' for a S3 storage connector
1833
+ c.locations('gs://my_bucket/path/to/folder') # list all objects in 'my_bucket/path/to/folder' for a GCP storage connector
1834
+ c.locations('az://my_container/path/to/folder') # list all objects in 'my_container/path/to/folder' for a AZURE storage connector
1835
+ ```
1836
+ """
1830
1837
  return self.client._locations(connector_id=self.id, prefix=prefix)
1831
1838
 
1832
1839
  def schema(self, location: str) -> list[dict[str, Any]]:
1833
1840
  """
1834
1841
  Retrieve the schema of the table at a connector location.
1835
- Please refer to `locations()` for the format of the location.
1842
+ This method is available for all connectors.
1836
1843
 
1837
1844
  Args:
1838
1845
  location (str): The location of the table.
1839
1846
 
1840
1847
  Returns:
1841
1848
  list[dict[str, Any]]: The retrieved schema.
1849
+
1850
+ Example:
1851
+ ```python
1852
+ c.schema('db_name.table_name') # get the schema of 'table_name' in 'db_name' for a DB connector
1853
+ c.schema('s3://my_bucket/path/to/file.csv') # get the schema of 'file.csv' in 'my_bucket' for a S3 storage connector
1854
+ ```
1842
1855
  """
1843
1856
  return self.client._schema(connector_id=self.id, location=location)
1844
1857
 
1845
1858
  def read_data(self, location: str, limit: int | None = None, shuffle: bool = False) -> pd.DataFrame:
1846
1859
  """
1847
1860
  Retrieve data from the specified location within the connector.
1861
+ This method is only available for connectors of access_type READ_DATA or WRITE_DATA.
1848
1862
 
1849
1863
  Args:
1850
1864
  location (str): The target location within the connector to read data from.
@@ -1853,6 +1867,12 @@ class Connector(CustomBaseModel):
1853
1867
 
1854
1868
  Returns:
1855
1869
  pd.DataFrame: A DataFrame containing the retrieved data.
1870
+
1871
+ Example:
1872
+ ```python
1873
+ df = c.read_data('db_name.table_name', limit=100) # fetch first 100 rows from 'table_name' in 'db_name' for a DB connector
1874
+ df = c.read_data('s3://my_bucket/path/to/file.csv') # read all data from 'file.csv' in 'my_bucket' for a S3 storage connector
1875
+ ```
1856
1876
  """
1857
1877
  return self.client._read_data(connector_id=self.id, location=location, limit=limit, shuffle=shuffle)
1858
1878
 
@@ -1864,20 +1884,34 @@ class Connector(CustomBaseModel):
1864
1884
  ) -> None:
1865
1885
  """
1866
1886
  Write data to the specified location within the connector.
1887
+ This method is only available for connectors of access_type WRITE_DATA.
1867
1888
 
1868
1889
  Args:
1869
1890
  data (pd.DataFrame | None): The DataFrame to write, or None to delete the location.
1870
1891
  location (str): The target location within the connector to write data to.
1871
1892
  if_exists (Literal["append", "replace", "fail"]): The behavior if the target location already exists (append, replace, fail). Default is "fail".
1893
+
1894
+ Example:
1895
+ ```python
1896
+ c.write_data(df, 'db_name.table_name', if_exists='fail') # write data to 'table_name' in 'db_name' for a DB connector (if it doesn't exist)
1897
+ c.write_data(df, 's3://my_bucket/path/to/file.csv') # write data to 'file.csv' in 'my_bucket' for a S3 storage connector
1898
+ ```
1872
1899
  """
1873
1900
  self.client._write_data(connector_id=self.id, data=data, location=location, if_exists=if_exists)
1874
1901
 
1875
1902
  def delete_data(self, location: str) -> None:
1876
1903
  """
1877
1904
  Delete data from the specified location within the connector.
1905
+ This method is only available for connectors of access_type WRITE_DATA.
1878
1906
 
1879
1907
  Args:
1880
1908
  location (str): The target location within the connector to delete data from.
1909
+
1910
+ Example:
1911
+ ```python
1912
+ c.delete_data('db_name.table_name') # drop table data from 'table_name' in 'db_name' for a DB connector
1913
+ c.delete_data('s3://my_bucket/path/to/file.csv') # delete data from 'file.csv' in 'my_bucket' for a S3 storage connector
1914
+ ```
1881
1915
  """
1882
1916
  self.client._delete_data(connector_id=self.id, location=location)
1883
1917
 
@@ -1886,14 +1920,21 @@ class Connector(CustomBaseModel):
1886
1920
  Execute a read-only SQL query against the connector's data source.
1887
1921
 
1888
1922
  Queries can include statements like SELECT, SHOW, or DESCRIBE, but must not modify data or state.
1889
- For file-based connectors (e.g., local files or cloud storage buckets like AWS S3, GCP, Azure Blob),
1890
- queries are executed using DuckDB.
1923
+ For file-based connectors (S3_STORAGE, GOOGLE_CLOUD_STORAGE, AZURE_STORAGE) queries are executed using DuckDB.
1891
1924
 
1892
1925
  Args:
1893
1926
  sql (str): The SQL query to execute.
1894
1927
 
1895
1928
  Returns:
1896
1929
  pd.DataFrame: The result of the query as a Pandas DataFrame.
1930
+
1931
+ Example:
1932
+ ```python
1933
+ df = c.query("SELECT count(*) FROM schema.table") # for DB connectors
1934
+ df = c.query("SELECT count(*) FROM read_csv_auto('s3://bucket/path/to/file.csv')") # query a single CSV file from S3 storage
1935
+ df = c.query("SELECT count(*) FROM read_parquet('gs://bucket/path/to/folder/*.parquet')") # query a folder with PQT files from GCP storage
1936
+ df = c.query("SELECT count(*) FROM read_json('az://bucket/path/to/file.json')") # query a single JSON file from AZURE storage
1937
+ ```
1897
1938
  """
1898
1939
  return self.client._query(connector_id=self.id, sql=sql)
1899
1940
 
@@ -2034,35 +2075,36 @@ class ModelConfiguration(CustomBaseModel):
2034
2075
  alias="maxSampleSize",
2035
2076
  description="The maximum number of samples to consider for training.\nIf not provided, then all available samples will be taken.\n",
2036
2077
  ge=1,
2037
- le=1000000000,
2038
2078
  )
2039
2079
  batch_size: int | None = Field(
2040
2080
  None,
2041
2081
  alias="batchSize",
2042
- description="The batch size used for training the model.\nIf not provided, batchSize will be chosen automatically.\n",
2082
+ description="The physical batch size used for training the model.\nIf not provided, batchSize will be chosen automatically.\n",
2083
+ ge=1,
2084
+ )
2085
+ gradient_accumulation_steps: int | None = Field(
2086
+ None,
2087
+ alias="gradientAccumulationSteps",
2088
+ description="Steps to accumulate gradients before optimizer update.\nIf not provided, gradientAccumulationSteps will be chosen automatically.\n",
2043
2089
  ge=1,
2044
- le=1000000,
2045
2090
  )
2046
2091
  max_training_time: float | None = Field(
2047
2092
  14400,
2048
2093
  alias="maxTrainingTime",
2049
2094
  description="The maximum number of minutes to train the model.",
2050
2095
  ge=0.0,
2051
- le=1000000.0,
2052
2096
  )
2053
2097
  max_epochs: float | None = Field(
2054
2098
  100,
2055
2099
  alias="maxEpochs",
2056
2100
  description="The maximum number of epochs to train the model.",
2057
2101
  ge=0.0,
2058
- le=1000000.0,
2059
2102
  )
2060
2103
  max_sequence_window: int | None = Field(
2061
2104
  100,
2062
2105
  alias="maxSequenceWindow",
2063
2106
  description="The maximum sequence window to consider for training.\nOnly applicable for TABULAR models.\n",
2064
2107
  ge=1,
2065
- le=100000,
2066
2108
  )
2067
2109
  enable_flexible_generation: bool | None = Field(
2068
2110
  True,
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.4.6"
3
+ version = "4.4.8"
4
4
  description = "Synthetic Data SDK"
5
5
  authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
6
6
  requires-python = ">=3.10,<3.14"
@@ -49,7 +49,7 @@ dependencies = [
49
49
  local = [
50
50
  # local
51
51
  "mostlyai-engine==1.1.11",
52
- "mostlyai-qa==1.5.12",
52
+ "mostlyai-qa==1.5.13",
53
53
  "fastapi>=0.115.6,<0.116",
54
54
  "uvicorn>=0.34.0,<0.35",
55
55
  "python-multipart>=0.0.20",
@@ -74,7 +74,7 @@ local = [
74
74
  ]
75
75
  local-gpu = [
76
76
  "mostlyai-engine[gpu]==1.1.11",
77
- "mostlyai-qa[gpu]==1.5.12",
77
+ "mostlyai-qa[gpu]==1.5.13",
78
78
  "fastapi>=0.115.6,<0.116",
79
79
  "uvicorn>=0.34.0,<0.35",
80
80
  "python-multipart>=0.0.20",
@@ -99,7 +99,7 @@ local-gpu = [
99
99
  ]
100
100
  local-cpu = [
101
101
  "mostlyai-engine[cpu]==1.1.11",
102
- "mostlyai-qa[cpu]==1.5.12",
102
+ "mostlyai-qa[cpu]==1.5.13",
103
103
  "fastapi>=0.115.6,<0.116",
104
104
  "uvicorn>=0.34.0,<0.35",
105
105
  "python-multipart>=0.0.20",
File without changes
File without changes
File without changes