mostlyai 4.8.1__tar.gz → 4.8.3__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.8.1 → mostlyai-4.8.3}/PKG-INFO +4 -4
  2. {mostlyai-4.8.1 → mostlyai-4.8.3}/README.md +1 -1
  3. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/base.py +8 -3
  5. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/base.py +1 -0
  6. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/pull.py +1 -2
  7. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/pull_context.py +2 -2
  8. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/pull_utils.py +1 -10
  9. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/jobs.py +9 -2
  10. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_finalize_generation.py +3 -1
  11. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/progress.py +6 -9
  12. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/_base_utils.py +1 -1
  13. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/_utils.py +10 -12
  14. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/generators.py +3 -3
  15. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/synthetic_datasets.py +5 -3
  16. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/domain.py +3 -5
  17. {mostlyai-4.8.1 → mostlyai-4.8.3}/pyproject.toml +3 -3
  18. {mostlyai-4.8.1 → mostlyai-4.8.3}/.gitignore +0 -0
  19. {mostlyai-4.8.1 → mostlyai-4.8.3}/LICENSE +0 -0
  20. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/__init__.py +0 -0
  21. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/auto_detect.py +0 -0
  22. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/context.py +0 -0
  23. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/conversions.py +0 -0
  24. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/__init__.py +0 -0
  25. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  26. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/databricks.py +0 -0
  27. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/hive.py +0 -0
  28. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/mssql.py +0 -0
  29. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/mysql.py +0 -0
  30. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/oracle.py +0 -0
  31. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  32. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  33. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  34. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  35. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/dtype.py +0 -0
  36. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/exceptions.py +0 -0
  37. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/__init__.py +0 -0
  38. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/base.py +0 -0
  39. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  40. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  41. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  42. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  43. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  44. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  45. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  46. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  47. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  48. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/table/json.py +0 -0
  49. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  50. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/file/utils.py +0 -0
  51. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/language_model.py +0 -0
  52. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  53. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/non_context.py +0 -0
  54. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/progress_callback.py +0 -0
  55. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/push.py +0 -0
  56. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/util/__init__.py +0 -0
  57. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/util/common.py +0 -0
  58. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  59. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/__init__.py +0 -0
  60. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/cli.py +0 -0
  61. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/connectors.py +0 -0
  62. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  63. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/migration.py +0 -0
  64. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/plan.py +0 -0
  65. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  66. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  67. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  68. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  69. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  70. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  71. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  72. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  73. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  74. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  75. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/generators.py +0 -0
  76. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/routes.py +0 -0
  77. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/server.py +0 -0
  78. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/storage.py +0 -0
  79. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  80. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/__init__.py +0 -0
  81. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  82. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/api.py +0 -0
  83. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/base.py +0 -0
  84. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/connectors.py +0 -0
  85. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/client/exceptions.py +0 -0
  86. {mostlyai-4.8.1 → mostlyai-4.8.3}/mostlyai/sdk/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mostlyai
3
- Version: 4.8.1
3
+ Version: 4.8.3
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
@@ -59,7 +59,7 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
59
59
  Requires-Dist: filelock>=3.16.1; extra == 'local'
60
60
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
61
61
  Requires-Dist: joblib>=1.4.2; extra == 'local'
62
- Requires-Dist: mostlyai-engine==1.4.6; extra == 'local'
62
+ Requires-Dist: mostlyai-engine==1.4.8; extra == 'local'
63
63
  Requires-Dist: mostlyai-qa==1.9.8; extra == 'local'
64
64
  Requires-Dist: networkx<4,>=3.0; extra == 'local'
65
65
  Requires-Dist: openpyxl>=3.1.5; extra == 'local'
@@ -81,7 +81,7 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
81
81
  Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
82
82
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
83
83
  Requires-Dist: joblib>=1.4.2; extra == 'local-gpu'
84
- Requires-Dist: mostlyai-engine[gpu]==1.4.6; extra == 'local-gpu'
84
+ Requires-Dist: mostlyai-engine[gpu]==1.4.8; extra == 'local-gpu'
85
85
  Requires-Dist: mostlyai-qa==1.9.8; extra == 'local-gpu'
86
86
  Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
87
87
  Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
@@ -193,7 +193,7 @@ df = mostly.probe(g, size=1000)
193
193
  df
194
194
  ```
195
195
 
196
- Generate synthetic sampels based on fixed column values:
196
+ Generate synthetic samples based on fixed column values:
197
197
 
198
198
  ```python
199
199
  # create 10k records of 24y male respondents
@@ -84,7 +84,7 @@ df = mostly.probe(g, size=1000)
84
84
  df
85
85
  ```
86
86
 
87
- Generate synthetic sampels based on fixed column values:
87
+ Generate synthetic samples based on fixed column values:
88
88
 
89
89
  ```python
90
90
  # create 10k records of 24y male respondents
@@ -15,4 +15,4 @@
15
15
  from mostlyai.sdk.client.api import MostlyAI
16
16
 
17
17
  __all__ = ["MostlyAI"]
18
- __version__ = "4.8.1" # Do not set this manually. Use poetry version [params].
18
+ __version__ = "4.8.3" # Do not set this manually. Use poetry version [params].
@@ -258,7 +258,7 @@ class Schema:
258
258
  relations = [rel for rel in relations if isinstance(rel, ContextRelation)]
259
259
  return relations
260
260
 
261
- def update_key_encoding_types(self) -> None:
261
+ def _update_key_encoding_types(self) -> None:
262
262
  for tbl_name, tbl_table in self.tables.items():
263
263
  if tbl_table.primary_key is not None:
264
264
  if tbl_table.primary_key in tbl_table.encoding_types:
@@ -268,7 +268,7 @@ class Schema:
268
268
  del tbl_table.encoding_types[rel.child.column]
269
269
  self.tables[tbl_name] = tbl_table
270
270
 
271
- def resolve_auto_encoding_types(self) -> None:
271
+ def _resolve_auto_encoding_types(self) -> None:
272
272
  for tbl_name, tbl_table in self.tables.items():
273
273
  for col_name, encoding_type in tbl_table.encoding_types.items():
274
274
  if encoding_type == ModelEncodingType.auto:
@@ -279,7 +279,7 @@ class Schema:
279
279
  f"{promoted_enctype.value} for {tbl_name}.{col_name}"
280
280
  )
281
281
 
282
- def remove_cascading_keys_relations(self):
282
+ def _remove_cascading_keys_relations(self):
283
283
  tables_with_cascading_keys = set()
284
284
  for table_name, table in self.tables.items():
285
285
  primary_key = table.primary_key
@@ -297,6 +297,11 @@ class Schema:
297
297
  if tables_with_cascading_keys:
298
298
  _LOG.info(f"Removed cascading keys relations for tables: {tables_with_cascading_keys}")
299
299
 
300
+ def preprocess_schema_before_pull(self):
301
+ self._remove_cascading_keys_relations()
302
+ self._update_key_encoding_types()
303
+ self._resolve_auto_encoding_types()
304
+
300
305
  @property
301
306
  @functools.cache
302
307
  def graph(self):
@@ -739,6 +739,7 @@ class SqlAlchemyContainer(DBContainer, abc.ABC):
739
739
  self.update_dbschema(None)
740
740
  return sorted(list(set(self.all_schemas())))
741
741
  else:
742
+ prefix = prefix.rstrip(".") # remove trailing dot if present
742
743
  # List the tables of the provided schema named {prefix}
743
744
  self.update_dbschema(prefix)
744
745
  locations = [".".join([prefix, loc]) for loc in self.get_object_list()]
@@ -21,7 +21,6 @@ from mostlyai.sdk._data.base import Schema
21
21
  from mostlyai.sdk._data.progress_callback import ProgressCallback, ProgressCallbackWrapper
22
22
  from mostlyai.sdk._data.pull_utils import (
23
23
  handle_workspace_dir,
24
- prepare_schema,
25
24
  pull_fetch,
26
25
  pull_keys,
27
26
  pull_split,
@@ -48,7 +47,7 @@ def pull(
48
47
  model_type = ModelType(model_type)
49
48
  if tgt not in schema.tables:
50
49
  raise ValueError(f"table '{tgt}' not defined in schema")
51
- prepare_schema(schema)
50
+ schema.preprocess_schema_before_pull()
52
51
  # gather context_tables
53
52
  context_tables = schema.get_context_tables(tgt)
54
53
  _LOG.info(f"context_tables (size: {len(context_tables)}): {context_tables}")
@@ -19,7 +19,7 @@ from typing import Any
19
19
 
20
20
  from mostlyai.sdk._data.base import Schema
21
21
  from mostlyai.sdk._data.progress_callback import ProgressCallbackWrapper
22
- from mostlyai.sdk._data.pull_utils import handle_workspace_dir, prepare_schema, pull_split
22
+ from mostlyai.sdk._data.pull_utils import handle_workspace_dir, pull_split
23
23
  from mostlyai.sdk.domain import ModelType
24
24
 
25
25
  _LOG = logging.getLogger(__name__)
@@ -38,7 +38,7 @@ def pull_context(
38
38
  model_type = ModelType(model_type)
39
39
  if tgt not in schema.tables:
40
40
  raise ValueError(f"table '{tgt}' not defined in schema")
41
- prepare_schema(schema)
41
+ schema.preprocess_schema_before_pull()
42
42
  # gather context_tables
43
43
  context_tables = schema.get_context_tables(tgt)
44
44
  _LOG.info(f"context_tables (size: {len(context_tables)}): {context_tables}")
@@ -642,7 +642,7 @@ def remake_schema_after_pull_fetch(tgt: str, schema: Schema, workspace_dir: Path
642
642
  fs_table.encoding_types = table.encoding_types
643
643
  tables[table_name] = fs_table
644
644
  schema = Schema(tables=tables)
645
- prepare_schema(schema)
645
+ schema.preprocess_schema_before_pull()
646
646
  return schema
647
647
 
648
648
 
@@ -1052,12 +1052,3 @@ def pull_split(
1052
1052
  )
1053
1053
  _LOG.info(f"meta exported in {time.time() - t0:.2f}s")
1054
1054
  _LOG.info(f"BYE FROM PULL_SPLIT (total time: {time.time() - t00:.2f}s)")
1055
-
1056
-
1057
- def prepare_schema(schema: Schema):
1058
- # update schema's relations to exclude unsupported cascading keys
1059
- schema.remove_cascading_keys_relations()
1060
- # update encoding_types for key columns, based on provided Schema
1061
- schema.update_key_encoding_types()
1062
- # resolve AUTO encoding types
1063
- schema.resolve_auto_encoding_types()
@@ -122,20 +122,25 @@ def _move_generation_artefacts(synthetic_dataset_dir: Path, job_workspace_dir: P
122
122
  def _mark_in_progress(resource: Generator | SyntheticDataset, resource_dir: Path):
123
123
  if isinstance(resource, Generator):
124
124
  resource.training_status = ProgressStatus.in_progress
125
+ write_resource_to_json = write_generator_to_json
125
126
  else:
126
127
  resource.generation_status = ProgressStatus.in_progress
128
+ write_resource_to_json = write_synthetic_dataset_to_json
127
129
  job_progress = read_job_progress_from_json(resource_dir)
128
130
  job_progress.status = ProgressStatus.in_progress
129
131
  for step in job_progress.steps:
130
132
  step.status = ProgressStatus.in_progress
133
+ write_resource_to_json(resource_dir, resource)
131
134
  write_job_progress_to_json(resource_dir, job_progress)
132
135
 
133
136
 
134
137
  def _mark_done(resource: Generator | SyntheticDataset, resource_dir: Path):
135
138
  if isinstance(resource, Generator):
136
139
  resource.training_status = ProgressStatus.done
140
+ write_resource_to_json = write_generator_to_json
137
141
  else:
138
142
  resource.generation_status = ProgressStatus.done
143
+ write_resource_to_json = write_synthetic_dataset_to_json
139
144
  now = get_current_utc_time()
140
145
  job_progress = read_job_progress_from_json(resource_dir)
141
146
  job_progress.status = ProgressStatus.done
@@ -147,19 +152,23 @@ def _mark_done(resource: Generator | SyntheticDataset, resource_dir: Path):
147
152
  step.start_date = step.start_date or now
148
153
  step.end_date = step.end_date or now
149
154
  step.progress.value = step.progress.max
155
+ write_resource_to_json(resource_dir, resource)
150
156
  write_job_progress_to_json(resource_dir, job_progress)
151
157
 
152
158
 
153
159
  def _mark_failed(resource: Generator | SyntheticDataset, resource_dir: Path):
154
160
  if isinstance(resource, Generator):
155
161
  resource.training_status = ProgressStatus.failed
162
+ write_resource_to_json = write_generator_to_json
156
163
  else:
157
164
  resource.generation_status = ProgressStatus.failed
165
+ write_resource_to_json = write_synthetic_dataset_to_json
158
166
  job_progress = read_job_progress_from_json(resource_dir)
159
167
  job_progress.status = ProgressStatus.failed
160
168
  for step in job_progress.steps:
161
169
  if step.status != ProgressStatus.done:
162
170
  step.status = ProgressStatus.failed
171
+ write_resource_to_json(resource_dir, resource)
163
172
  write_job_progress_to_json(resource_dir, job_progress)
164
173
 
165
174
 
@@ -607,7 +616,6 @@ def execute_training_job(generator_id: str, home_dir: Path):
607
616
  finally:
608
617
  execution.clear_job_workspace()
609
618
  execution.clear_file_upload_connectors()
610
- write_generator_to_json(generator_dir, generator)
611
619
 
612
620
  try:
613
621
  _probe_random_samples(home_dir=home_dir, generator=generator)
@@ -652,7 +660,6 @@ def execute_generation_job(synthetic_dataset_id: str, home_dir: Path):
652
660
  finally:
653
661
  execution.clear_job_workspace()
654
662
  execution.clear_file_upload_connectors()
655
- write_synthetic_dataset_to_json(synthetic_dataset_dir, synthetic_dataset)
656
663
 
657
664
 
658
665
  def execute_probing_job(synthetic_dataset_id: str, home_dir: Path) -> list[Probe]:
@@ -452,4 +452,6 @@ def create_generation_schema(
452
452
  for fk in table.foreign_keys or []
453
453
  ]
454
454
  tables[table.name] = data_table
455
- return Schema(tables=tables)
455
+ schema = Schema(tables=tables)
456
+ schema.preprocess_schema_before_pull()
457
+ return schema
@@ -13,14 +13,13 @@
13
13
  # limitations under the License.
14
14
 
15
15
  import datetime
16
- import json
17
16
  import math
18
17
  from pathlib import Path
19
18
 
20
19
  from pydantic import BaseModel
21
20
 
22
- from mostlyai.sdk._local.storage import write_to_json
23
- from mostlyai.sdk.domain import JobProgress, ProgressStatus, StepCode
21
+ from mostlyai.sdk._local.storage import read_job_progress_from_json, write_job_progress_to_json
22
+ from mostlyai.sdk.domain import ProgressStatus, StepCode
24
23
 
25
24
 
26
25
  def get_current_utc_time() -> datetime.datetime:
@@ -43,8 +42,7 @@ class LocalProgressCallback:
43
42
  self._last_send_progress_time = None
44
43
  self._total = None
45
44
 
46
- self.progress_file = self.resource_path / "job_progress.json"
47
- self.job_progress = JobProgress(**json.loads(self.progress_file.read_text()))
45
+ self.job_progress = read_job_progress_from_json(self.resource_path)
48
46
 
49
47
  def _check_elapsed_interval(self):
50
48
  now = get_current_utc_time()
@@ -119,9 +117,8 @@ class LocalProgressCallback:
119
117
  self.job_progress.progress.max = len(self.job_progress.steps) # of steps
120
118
  if self.job_progress.start_date is None:
121
119
  self.job_progress.start_date = now
122
- if self.job_progress.progress.value >= self.job_progress.progress.max:
123
- self.job_progress.end_date = now
124
- self.job_progress.status = ProgressStatus.done
120
+ # NOTE: do not set job status to DONE here, that should happen as the very last thing
121
+ # in order for `job_wait` not to finish polling prematurely
125
122
 
126
123
  # send progress if we are DONE, or if we have a message to pass,
127
124
  # or if enough time has passed since last progress update
@@ -133,6 +130,6 @@ class LocalProgressCallback:
133
130
  or (completed is not None and elapsed_enough_time)
134
131
  or (increase_by > 0 and elapsed_enough_time)
135
132
  ):
136
- write_to_json(self.progress_file, self.job_progress)
133
+ write_job_progress_to_json(self.resource_path, self.job_progress)
137
134
 
138
135
  return {}
@@ -72,7 +72,7 @@ def convert_to_df(data: str, format: Literal["parquet", "jsonl"] = "parquet") ->
72
72
  return df
73
73
 
74
74
 
75
- def read_table_from_path(path: str | Path) -> (str, pd.DataFrame):
75
+ def read_table_from_path(path: str | Path) -> tuple[str, pd.DataFrame]:
76
76
  # read data from file
77
77
  fn = str(path)
78
78
  if fn.lower().endswith((".pqt", ".parquet")):
@@ -288,18 +288,16 @@ def job_wait(
288
288
  if step.status in (ProgressStatus.failed, ProgressStatus.canceled):
289
289
  rich.print(f"[red]Step {step.model_label} {step.step_code.value} {step.status.lower()}")
290
290
  return
291
- # check whether we are done
292
- if job.progress.value >= job.progress.max:
293
- live.refresh()
294
- time.sleep(1) # give the system a moment to update the status
295
- return
296
- else:
297
- if job.end_date or job.progress in (
298
- ProgressStatus.failed,
299
- ProgressStatus.canceled,
300
- ):
301
- rich.print(f"Job {job.status.lower()}")
302
- return
291
+
292
+ # check whether we are done
293
+ if job.status in (
294
+ ProgressStatus.done,
295
+ ProgressStatus.failed,
296
+ ProgressStatus.canceled,
297
+ ):
298
+ live.refresh()
299
+ time.sleep(1) # give the system a moment to update the status
300
+ return
303
301
  except KeyboardInterrupt:
304
302
  rich.print(f"[red]Step {step.model_label} {step.step_code.value} {step.status.lower()}")
305
303
  return
@@ -267,7 +267,7 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
267
267
  def _export_to_file(
268
268
  self,
269
269
  generator_id: str,
270
- ) -> (bytes, str | None):
270
+ ) -> tuple[bytes, str | None]:
271
271
  response = self.request(
272
272
  verb=GET,
273
273
  path=[generator_id, "export-to-file"],
@@ -318,7 +318,7 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
318
318
  source_table_id: str,
319
319
  model_type: ModelType = ModelType.tabular,
320
320
  short_lived_file_token: str | None = None,
321
- ) -> (str, str | None):
321
+ ) -> tuple[str, str | None]:
322
322
  response = self.request(
323
323
  verb=GET,
324
324
  path=[generator_id, "tables", source_table_id, "report"],
@@ -348,7 +348,7 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
348
348
  generator = self.get(generator_id)
349
349
  return generator
350
350
 
351
- def _training_logs(self, generator_id: str, short_lived_file_token: str | None = None) -> (bytes, str):
351
+ def _training_logs(self, generator_id: str, short_lived_file_token: str | None = None) -> tuple[bytes, str]:
352
352
  response = self.request(
353
353
  verb=GET,
354
354
  path=[generator_id, "training", "logs"],
@@ -213,7 +213,7 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
213
213
  synthetic_dataset_id: str,
214
214
  ds_format: SyntheticDatasetFormat = SyntheticDatasetFormat.parquet,
215
215
  short_lived_file_token: str | None = None,
216
- ) -> (bytes, str | None):
216
+ ) -> tuple[bytes, str | None]:
217
217
  response = self.request(
218
218
  verb=GET,
219
219
  path=[synthetic_dataset_id, "download"],
@@ -261,7 +261,7 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
261
261
  model_type: ModelType = ModelType.tabular,
262
262
  report_type: SyntheticDatasetReportType = SyntheticDatasetReportType.model,
263
263
  short_lived_file_token: str | None = None,
264
- ) -> (str, str | None):
264
+ ) -> tuple[str, str | None]:
265
265
  response = self.request(
266
266
  verb=GET,
267
267
  path=[synthetic_dataset_id, "tables", synthetic_table_id, "report"],
@@ -300,7 +300,9 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
300
300
  synthetic_dataset = self.get(synthetic_dataset_id)
301
301
  return synthetic_dataset
302
302
 
303
- def _generation_logs(self, synthetic_dataset_id: str, short_lived_file_token: str | None = None) -> (bytes, str):
303
+ def _generation_logs(
304
+ self, synthetic_dataset_id: str, short_lived_file_token: str | None = None
305
+ ) -> tuple[bytes, str]:
304
306
  response = self.request(
305
307
  verb=GET,
306
308
  path=[synthetic_dataset_id, "generation", "logs"],
@@ -2680,11 +2680,9 @@ class SourceTableConfig(CustomBaseModel):
2680
2680
  else:
2681
2681
  has_tabular_model = True
2682
2682
  has_language_model = False
2683
- if values.foreign_keys:
2684
- # Always train tabular model for linked tables to model sequences
2685
- for fk in values.foreign_keys:
2686
- if fk.is_context:
2687
- has_tabular_model = True
2683
+ # Always train tabular model for tables with a primary key or linked tables to model sequences
2684
+ if values.primary_key or (values.foreign_keys and any(fk.is_context for fk in values.foreign_keys)):
2685
+ has_tabular_model = True
2688
2686
  # Remove model configurations that are not applicable for the model type
2689
2687
  if values.tabular_model_configuration and not has_tabular_model:
2690
2688
  values.tabular_model_configuration = None
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.8.1"
3
+ version = "4.8.3"
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
  # "mostlyai-engine @ git+https://github.com/mostly-ai/mostlyai-engine.git@main", # for development
51
51
  # "mostlyai-qa @ git+https://github.com/mostly-ai/mostlyai-qa.git@main", # for development
52
- "mostlyai-engine==1.4.6", # for release
52
+ "mostlyai-engine==1.4.8", # for release
53
53
  "mostlyai-qa==1.9.8", # for release
54
54
  "fastapi>=0.115.6,<0.116",
55
55
  "uvicorn>=0.34.0,<0.35",
@@ -75,7 +75,7 @@ local = [
75
75
  local-gpu = [
76
76
  # "mostlyai-engine[gpu] @ git+https://github.com/mostly-ai/mostlyai-engine.git@main", # for development
77
77
  # "mostlyai-qa @ git+https://github.com/mostly-ai/mostlyai-qa.git@main", # for development
78
- "mostlyai-engine[gpu]==1.4.6", # for release
78
+ "mostlyai-engine[gpu]==1.4.8", # for release
79
79
  "mostlyai-qa==1.9.8", # for release
80
80
  "fastapi>=0.115.6,<0.116",
81
81
  "uvicorn>=0.34.0,<0.35",
File without changes
File without changes
File without changes