mostlyai 6.2.1__tar.gz → 6.3.0__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 (89) hide show
  1. {mostlyai-6.2.1 → mostlyai-6.3.0}/PKG-INFO +21 -20
  2. {mostlyai-6.2.1 → mostlyai-6.3.0}/README.md +12 -11
  3. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/auto_detect.py +4 -2
  5. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/base.py +8 -20
  6. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/constraints/transformations.py +2 -2
  7. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/constraints/types/base.py +0 -4
  8. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/context.py +6 -6
  9. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/base.py +6 -6
  10. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/bigquery.py +2 -2
  11. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/mssql.py +1 -1
  12. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/oracle.py +1 -1
  13. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/postgresql.py +1 -1
  14. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/dtype.py +8 -18
  15. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/base.py +4 -4
  16. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/container/aws.py +4 -4
  17. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/container/azure.py +3 -3
  18. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/container/bucket_based.py +2 -2
  19. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/container/gcs.py +2 -2
  20. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/table/csv.py +1 -1
  21. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/utils.py +1 -1
  22. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/non_context.py +2 -2
  23. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/pull_utils.py +9 -9
  24. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/push.py +1 -1
  25. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/util/common.py +2 -2
  26. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/connectors.py +7 -7
  27. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/docker_entrypoint.py +1 -1
  28. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/jobs.py +4 -6
  29. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/migration.py +1 -1
  30. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/plan.py +3 -1
  31. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +2 -2
  32. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_create_model_report.py +14 -14
  33. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_deliver_data.py +1 -1
  34. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_finalize_generation.py +3 -3
  35. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_finalize_training.py +2 -2
  36. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_generate_data.py +22 -11
  37. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/generators.py +2 -6
  38. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/routes.py +5 -5
  39. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/server.py +1 -1
  40. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/synthetic_datasets.py +1 -5
  41. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/_constraint_types.py +0 -1
  42. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/_utils.py +1 -1
  43. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/api.py +7 -7
  44. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/base.py +1 -1
  45. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/exceptions.py +1 -1
  46. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/generators.py +1 -1
  47. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/synthetic_datasets.py +1 -1
  48. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/domain.py +13 -17
  49. {mostlyai-6.2.1 → mostlyai-6.3.0}/pyproject.toml +22 -13
  50. {mostlyai-6.2.1 → mostlyai-6.3.0}/.gitignore +0 -0
  51. {mostlyai-6.2.1 → mostlyai-6.3.0}/LICENSE +0 -0
  52. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/__init__.py +0 -0
  53. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/constraints/types/__init__.py +0 -0
  54. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/constraints/types/fixed_combinations.py +0 -0
  55. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/constraints/types/inequality.py +0 -0
  56. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/conversions.py +0 -0
  57. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/__init__.py +0 -0
  58. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/mysql.py +0 -0
  59. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  60. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  61. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/exceptions.py +0 -0
  62. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/__init__.py +0 -0
  63. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  64. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  65. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  66. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  67. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/table/json.py +0 -0
  68. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  69. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/language_model.py +0 -0
  70. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  71. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/progress_callback.py +0 -0
  72. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/pull.py +0 -0
  73. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/pull_context.py +0 -0
  74. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_data/util/__init__.py +0 -0
  75. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/__init__.py +0 -0
  76. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/cli.py +0 -0
  77. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  78. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  79. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  80. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  81. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  82. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  83. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/progress.py +0 -0
  84. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/_local/storage.py +0 -0
  85. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/__init__.py +0 -0
  86. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/_base_utils.py +0 -0
  87. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  88. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/client/connectors.py +0 -0
  89. {mostlyai-6.2.1 → mostlyai-6.3.0}/mostlyai/sdk/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: mostlyai
3
- Version: 6.2.1
3
+ Version: 6.3.0
4
4
  Summary: Synthetic Data SDK
5
5
  Project-URL: homepage, https://mostly.ai/
6
6
  Project-URL: repository, https://github.com/mostly-ai/mostlyai
@@ -53,8 +53,8 @@ Requires-Dist: fastapi>=0.116.0; extra == 'local'
53
53
  Requires-Dist: filelock>=3.16.1; extra == 'local'
54
54
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
55
55
  Requires-Dist: joblib>=1.4.2; extra == 'local'
56
- Requires-Dist: mostlyai-engine==2.7.4; extra == 'local'
57
- Requires-Dist: mostlyai-qa==1.10.11; extra == 'local'
56
+ Requires-Dist: mostlyai-engine==2.8.1; extra == 'local'
57
+ Requires-Dist: mostlyai-qa==1.10.12; extra == 'local'
58
58
  Requires-Dist: networkx<4,>=3.0; extra == 'local'
59
59
  Requires-Dist: openpyxl>=3.1.5; extra == 'local'
60
60
  Requires-Dist: python-multipart>=0.0.20; extra == 'local'
@@ -62,9 +62,9 @@ Requires-Dist: s3fs>=2023.1.0; extra == 'local'
62
62
  Requires-Dist: smart-open[azure,gcs,s3]>=6.3.0; extra == 'local'
63
63
  Requires-Dist: sqlalchemy>=2.0.0; extra == 'local'
64
64
  Requires-Dist: sshtunnel<0.5,>=0.4.0; extra == 'local'
65
- Requires-Dist: torch<2.14.0,>=2.13.0; extra == 'local'
65
+ Requires-Dist: torch<2.15.0,>=2.14.0; extra == 'local'
66
66
  Requires-Dist: torchaudio<2.12.0,>=2.11.0; extra == 'local'
67
- Requires-Dist: torchvision<0.29.0,>=0.28.0; extra == 'local'
67
+ Requires-Dist: torchvision<0.30.0,>=0.29.0; extra == 'local'
68
68
  Requires-Dist: uvicorn>=0.34.0; extra == 'local'
69
69
  Requires-Dist: xlsxwriter<4,>=3.1.9; extra == 'local'
70
70
  Provides-Extra: local-gpu
@@ -75,8 +75,8 @@ Requires-Dist: fastapi>=0.116.0; extra == 'local-gpu'
75
75
  Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
76
76
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
77
77
  Requires-Dist: joblib>=1.4.2; extra == 'local-gpu'
78
- Requires-Dist: mostlyai-engine[gpu]==2.7.4; extra == 'local-gpu'
79
- Requires-Dist: mostlyai-qa==1.10.11; extra == 'local-gpu'
78
+ Requires-Dist: mostlyai-engine[gpu]==2.8.1; extra == 'local-gpu'
79
+ Requires-Dist: mostlyai-qa==1.10.12; extra == 'local-gpu'
80
80
  Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
81
81
  Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
82
82
  Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
@@ -84,9 +84,9 @@ Requires-Dist: s3fs>=2023.1.0; extra == 'local-gpu'
84
84
  Requires-Dist: smart-open[azure,gcs,s3]>=6.3.0; extra == 'local-gpu'
85
85
  Requires-Dist: sqlalchemy>=2.0.0; extra == 'local-gpu'
86
86
  Requires-Dist: sshtunnel<0.5,>=0.4.0; extra == 'local-gpu'
87
- Requires-Dist: torch<2.14.0,>=2.13.0; extra == 'local-gpu'
87
+ Requires-Dist: torch<2.15.0,>=2.14.0; extra == 'local-gpu'
88
88
  Requires-Dist: torchaudio<2.12.0,>=2.11.0; extra == 'local-gpu'
89
- Requires-Dist: torchvision<0.29.0,>=0.28.0; extra == 'local-gpu'
89
+ Requires-Dist: torchvision<0.30.0,>=0.29.0; extra == 'local-gpu'
90
90
  Requires-Dist: uvicorn>=0.34.0; extra == 'local-gpu'
91
91
  Requires-Dist: xlsxwriter<4,>=3.1.9; extra == 'local-gpu'
92
92
  Provides-Extra: mssql
@@ -171,11 +171,12 @@ Generate synthetic samples using a pre-trained generator:
171
171
  ```python
172
172
  # initialize the SDK
173
173
  from mostlyai.sdk import MostlyAI
174
+
174
175
  mostly = MostlyAI()
175
176
 
176
177
  # import a trained generator
177
178
  g = mostly.generators.import_from_file(
178
- "https://github.com/mostly-ai/public-demo-data/raw/dev/census/census-generator.zip"
179
+ "https://github.com/mostly-ai/public-demo-data/raw/dev/census/census-generator.zip"
179
180
  )
180
181
 
181
182
  # probe for 1000 representative synthetic samples
@@ -196,14 +197,13 @@ And now train your very own synthetic data generator:
196
197
  ```python
197
198
  # load original data
198
199
  import pandas as pd
199
- original_df = pd.read_csv(
200
- "https://github.com/mostly-ai/public-demo-data/raw/dev/titanic/titanic.csv"
201
- )
200
+
201
+ original_df = pd.read_csv("https://github.com/mostly-ai/public-demo-data/raw/dev/titanic/titanic.csv")
202
202
 
203
203
  # train a single-table generator, with default configs
204
204
  g = mostly.train(
205
- name="Quick Start Demo - Titanic",
206
- data=original_df,
205
+ name="Quick Start Demo - Titanic",
206
+ data=original_df,
207
207
  )
208
208
 
209
209
  # display the quality assurance report
@@ -307,12 +307,12 @@ On Linux, one can explicitly install the CPU-only variant of torch together with
307
307
 
308
308
  ```shell
309
309
  # uv pip install
310
- uv pip install --index-strategy unsafe-first-match -U torch==2.13.0+cpu torchvision==0.28.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
310
+ uv pip install --index-strategy unsafe-first-match -U torch==2.14.0+cpu torchvision==0.29.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
311
311
  ```
312
312
 
313
313
  ```shell
314
314
  # standard pip install
315
- pip install -U torch==2.13.0+cpu torchvision==0.28.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
315
+ pip install -U torch==2.14.0+cpu torchvision==0.29.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
316
316
  ```
317
317
 
318
318
  ### CLIENT mode
@@ -349,10 +349,10 @@ As an alternative, you can also build a Docker image, which provides you with an
349
349
  <code>docker pull --platform=linux/amd64 ghcr.io/mostly-ai/sdk</code>
350
350
 
351
351
  <ul>
352
- <li><strong>Pull from official repository</strong></li>
352
+ <li><strong>Build locally</strong></li>
353
353
  </ul>
354
354
 
355
- If your environment is capable of executing Makefile (see <a href="https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L47-L73">here</a>), then execute <code>make docker-build</code>.
355
+ If your environment is capable of executing Makefile (see <a href="https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L14-L39">here</a>), then execute <code>make docker-build</code>.
356
356
 
357
357
  Otherwise, use <code>docker buildx build . --platform=linux/amd64 -t ghcr.io/mostly-ai/sdk</code> instead.
358
358
 
@@ -400,8 +400,9 @@ If your application depends on a Hugging Face language model, you’ll also need
400
400
  #! uv pip install huggingface-hub
401
401
  from pathlib import Path
402
402
  from huggingface_hub import snapshot_download
403
+
403
404
  path = snapshot_download(
404
- repo_id="Qwen/Qwen2.5-Coder-0.5B", # change accordingly
405
+ repo_id="Qwen/Qwen3-0.6B", # change accordingly
405
406
  token=None, # insert your HF TOKEN for gated models
406
407
  )
407
408
  print(f"COPY `{Path(path).parent.parent}`")
@@ -70,11 +70,12 @@ Generate synthetic samples using a pre-trained generator:
70
70
  ```python
71
71
  # initialize the SDK
72
72
  from mostlyai.sdk import MostlyAI
73
+
73
74
  mostly = MostlyAI()
74
75
 
75
76
  # import a trained generator
76
77
  g = mostly.generators.import_from_file(
77
- "https://github.com/mostly-ai/public-demo-data/raw/dev/census/census-generator.zip"
78
+ "https://github.com/mostly-ai/public-demo-data/raw/dev/census/census-generator.zip"
78
79
  )
79
80
 
80
81
  # probe for 1000 representative synthetic samples
@@ -95,14 +96,13 @@ And now train your very own synthetic data generator:
95
96
  ```python
96
97
  # load original data
97
98
  import pandas as pd
98
- original_df = pd.read_csv(
99
- "https://github.com/mostly-ai/public-demo-data/raw/dev/titanic/titanic.csv"
100
- )
99
+
100
+ original_df = pd.read_csv("https://github.com/mostly-ai/public-demo-data/raw/dev/titanic/titanic.csv")
101
101
 
102
102
  # train a single-table generator, with default configs
103
103
  g = mostly.train(
104
- name="Quick Start Demo - Titanic",
105
- data=original_df,
104
+ name="Quick Start Demo - Titanic",
105
+ data=original_df,
106
106
  )
107
107
 
108
108
  # display the quality assurance report
@@ -206,12 +206,12 @@ On Linux, one can explicitly install the CPU-only variant of torch together with
206
206
 
207
207
  ```shell
208
208
  # uv pip install
209
- uv pip install --index-strategy unsafe-first-match -U torch==2.13.0+cpu torchvision==0.28.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
209
+ uv pip install --index-strategy unsafe-first-match -U torch==2.14.0+cpu torchvision==0.29.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
210
210
  ```
211
211
 
212
212
  ```shell
213
213
  # standard pip install
214
- pip install -U torch==2.13.0+cpu torchvision==0.28.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
214
+ pip install -U torch==2.14.0+cpu torchvision==0.29.0+cpu torchaudio==2.11.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
215
215
  ```
216
216
 
217
217
  ### CLIENT mode
@@ -248,10 +248,10 @@ As an alternative, you can also build a Docker image, which provides you with an
248
248
  <code>docker pull --platform=linux/amd64 ghcr.io/mostly-ai/sdk</code>
249
249
 
250
250
  <ul>
251
- <li><strong>Pull from official repository</strong></li>
251
+ <li><strong>Build locally</strong></li>
252
252
  </ul>
253
253
 
254
- If your environment is capable of executing Makefile (see <a href="https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L47-L73">here</a>), then execute <code>make docker-build</code>.
254
+ If your environment is capable of executing Makefile (see <a href="https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L14-L39">here</a>), then execute <code>make docker-build</code>.
255
255
 
256
256
  Otherwise, use <code>docker buildx build . --platform=linux/amd64 -t ghcr.io/mostly-ai/sdk</code> instead.
257
257
 
@@ -299,8 +299,9 @@ If your application depends on a Hugging Face language model, you’ll also need
299
299
  #! uv pip install huggingface-hub
300
300
  from pathlib import Path
301
301
  from huggingface_hub import snapshot_download
302
+
302
303
  path = snapshot_download(
303
- repo_id="Qwen/Qwen2.5-Coder-0.5B", # change accordingly
304
+ repo_id="Qwen/Qwen3-0.6B", # change accordingly
304
305
  token=None, # insert your HF TOKEN for gated models
305
306
  )
306
307
  print(f"COPY `{Path(path).parent.parent}`")
@@ -47,4 +47,4 @@ For more information, visit: https://mostly-ai.github.io/mostlyai/
47
47
  from mostlyai.sdk.client.api import MostlyAI
48
48
 
49
49
  __all__ = ["MostlyAI"]
50
- __version__ = "6.2.1" # Do not set this manually. Use poetry version [params].
50
+ __version__ = "6.3.0" # Do not set this manually. Use poetry version [params].
@@ -88,8 +88,10 @@ def auto_detect_encoding_type(x: pd.Series) -> ModelEncodingType:
88
88
  if len(x) == 0:
89
89
  return ModelEncodingType.tabular_categorical
90
90
 
91
- # if all non-null values can be converted to datetime -> datetime encoding
92
- if safe_convert_datetime(x).notna().all():
91
+ # if all non-null values can be converted to datetime within the datetime64[ns] range -> datetime encoding;
92
+ # month names or ordinals like "Jan" or "1st" parse to year 1, which datetime64[ns] cannot hold
93
+ datetimes = safe_convert_datetime(x)
94
+ if datetimes.notna().all() and datetimes.between(pd.Timestamp.min, pd.Timestamp.max).all():
93
95
  return ModelEncodingType.tabular_datetime
94
96
 
95
97
  # if all values match lat/long pattern -> lat_long (geo) encoding
@@ -242,7 +242,7 @@ class Schema:
242
242
  return vertical_context + horizontal_context
243
243
 
244
244
  def get_older_sibling_tables(self, parent: str, child: str) -> list[str]:
245
- sibling_tables = reversed(sorted(self.get_context_children(parent)))
245
+ sibling_tables = sorted(self.get_context_children(parent), reverse=True)
246
246
  # only return siblings that are "older", i.e. that are alphabetically sorted before the child table
247
247
  sibling_tables = [t for t in sibling_tables if t < child]
248
248
  return sibling_tables
@@ -260,9 +260,8 @@ class Schema:
260
260
 
261
261
  def _update_key_encoding_types(self) -> None:
262
262
  for tbl_name, tbl_table in self.tables.items():
263
- if tbl_table.primary_key:
264
- if tbl_table.primary_key in tbl_table.encoding_types:
265
- del tbl_table.encoding_types[tbl_table.primary_key]
263
+ if tbl_table.primary_key and tbl_table.primary_key in tbl_table.encoding_types:
264
+ del tbl_table.encoding_types[tbl_table.primary_key]
266
265
  for rel in self.get_relations_to_table(tbl_name):
267
266
  if rel.child.column in tbl_table.encoding_types:
268
267
  del tbl_table.encoding_types[rel.child.column]
@@ -303,10 +302,10 @@ class Schema:
303
302
  self._resolve_auto_encoding_types()
304
303
 
305
304
  @property
306
- @functools.cache
305
+ @functools.cache # noqa: B019
307
306
  def graph(self):
308
307
  g = nx.MultiDiGraph()
309
- for table in self.tables.keys():
308
+ for table in self.tables:
310
309
  g.add_node(table)
311
310
  for rel in self.relations:
312
311
  g.add_edge(
@@ -386,9 +385,9 @@ class Schema:
386
385
  table_root = {}
387
386
  ctx_graph = self.subset(relation_type=ContextRelation).graph
388
387
  topological_order = list(nx.topological_sort(ctx_graph))
389
- for table in self.tables.keys():
388
+ for table in self.tables:
390
389
  ancestors = nx.ancestors(ctx_graph, table)
391
- table_root[table] = sorted(ancestors, key=lambda x: topological_order.index(x))[0] if ancestors else table
390
+ table_root[table] = min(ancestors, key=lambda x: topological_order.index(x)) if ancestors else table
392
391
 
393
392
  return table_root
394
393
 
@@ -448,7 +447,6 @@ class DataContainer(abc.ABC):
448
447
 
449
448
  :return: True if accessible, False otherwise
450
449
  """
451
- pass
452
450
 
453
451
  @abc.abstractmethod
454
452
  def query(self, sql: str) -> pd.DataFrame:
@@ -458,7 +456,6 @@ class DataContainer(abc.ABC):
458
456
  :param sql: SQL query to execute
459
457
  :return: DataFrame containing the query results
460
458
  """
461
- pass
462
459
 
463
460
  # DEFAULT METHODS (noop, unless applicable)
464
461
  def drop_all(self):
@@ -466,7 +463,6 @@ class DataContainer(abc.ABC):
466
463
  Drop all the relations and tables, if applicable.
467
464
 
468
465
  """
469
- pass
470
466
 
471
467
  def fetch_table(self, table_name: str):
472
468
  """
@@ -477,7 +473,6 @@ class DataContainer(abc.ABC):
477
473
  - their corresponding columns
478
474
  - PKs / FKs
479
475
  """
480
- pass
481
476
 
482
477
  def fetch_schema(self):
483
478
  """
@@ -489,7 +484,6 @@ class DataContainer(abc.ABC):
489
484
 
490
485
  Note: when a driver needs to configured: do it lazily or eagerly? applicable to DBs, mostly.
491
486
  """
492
- pass
493
487
 
494
488
  def set_location(self, location: str) -> dict:
495
489
  return {}
@@ -538,7 +532,6 @@ class DataTable(abc.ABC):
538
532
 
539
533
  :return: True if accessible, False otherwise
540
534
  """
541
- pass
542
535
 
543
536
  @property
544
537
  @abc.abstractmethod
@@ -546,7 +539,6 @@ class DataTable(abc.ABC):
546
539
  """
547
540
  Fetch number of rows (if possible)
548
541
  """
549
- pass
550
542
 
551
543
  @abc.abstractmethod
552
544
  def read_data(
@@ -568,7 +560,6 @@ class DataTable(abc.ABC):
568
560
  :param order_by: optionally, one or multiple columns (asc/desc) to order by
569
561
  :param do_coerce_dtypes: bool on whether dtypes shall be converted corresponding to encoding_types
570
562
  """
571
- pass
572
563
 
573
564
  @abc.abstractmethod
574
565
  def read_chunks(
@@ -588,7 +579,6 @@ class DataTable(abc.ABC):
588
579
  :param fetch_chunk_size: size of the chunk to fetch from the data source
589
580
  :param yield_chunk_size: size of the chunk to yield to the caller
590
581
  """
591
- pass
592
582
 
593
583
  @abc.abstractmethod
594
584
  def write_data(self, df: pd.DataFrame, **kwargs):
@@ -597,7 +587,6 @@ class DataTable(abc.ABC):
597
587
 
598
588
  :param df: data to write
599
589
  """
600
- pass
601
590
 
602
591
  @abc.abstractmethod
603
592
  def drop(self):
@@ -605,7 +594,6 @@ class DataTable(abc.ABC):
605
594
  Drop the data table.
606
595
 
607
596
  """
608
- pass
609
597
 
610
598
  def read_data_prefixed(self, include_table_prefix: bool = True, **kwargs) -> pd.DataFrame:
611
599
  """
@@ -688,7 +676,7 @@ class DataTable(abc.ABC):
688
676
  return
689
677
 
690
678
  old_new_k_map = {}
691
- for k in d.keys():
679
+ for k in d:
692
680
  if prefix not in k:
693
681
  new_k = DataIdentifier(table=self.name, column=k).ref_name()
694
682
  old_new_k_map[k] = new_k
@@ -49,7 +49,7 @@ def _create_constraint_handler(
49
49
  elif isinstance(constraint, Inequality):
50
50
  return InequalityHandler(constraint, table=table, workspace_dir=workspace_dir)
51
51
  else:
52
- raise ValueError(f"unknown constraint type: {type(constraint)}")
52
+ raise ValueError(f"unknown constraint type: {type(constraint)}") # noqa: TRY004
53
53
 
54
54
 
55
55
  class ConstraintTranslator:
@@ -153,7 +153,7 @@ def preprocess_constraints_for_training(
153
153
  _LOG.warning(f"data directory not found: {tgt_data_dir}")
154
154
  return None
155
155
 
156
- parquet_files = sorted(list(tgt_data_dir.glob("part.*.parquet")))
156
+ parquet_files = sorted(tgt_data_dir.glob("part.*.parquet"))
157
157
  for parquet_file in parquet_files:
158
158
  df = pd.read_parquet(parquet_file)
159
159
  df_transformed = constraint_translator.to_internal(df)
@@ -27,22 +27,18 @@ class ConstraintHandler(ABC):
27
27
  @abstractmethod
28
28
  def get_internal_column_names(self) -> list[str]:
29
29
  """return list of internal column names created by this handler."""
30
- pass
31
30
 
32
31
  @abstractmethod
33
32
  def to_internal(self, df: pd.DataFrame) -> pd.DataFrame:
34
33
  """transform dataframe (in-place) from user schema to internal schema."""
35
- pass
36
34
 
37
35
  @abstractmethod
38
36
  def to_original(self, df: pd.DataFrame) -> pd.DataFrame:
39
37
  """transform dataframe (in-place) from internal schema back to user schema."""
40
- pass
41
38
 
42
39
  @abstractmethod
43
40
  def get_encoding_types(self) -> dict[str, str]:
44
41
  """return encoding types for internal columns."""
45
- pass
46
42
 
47
43
  def _validate_columns(self, df: pd.DataFrame, columns: list[str]) -> None:
48
44
  """validate that all required columns exist in the dataframe."""
@@ -33,7 +33,7 @@ def add_gpc_context(
33
33
  tgt: str,
34
34
  ) -> pd.DataFrame:
35
35
  context_tables = schema.get_context_tables(tgt)
36
- ctx_tgt_nodes, ctx_tgt_path = get_table_chain_to_tgt(
36
+ ctx_tgt_nodes, _ctx_tgt_path = get_table_chain_to_tgt(
37
37
  schema=schema,
38
38
  tables=context_tables,
39
39
  tgt=tgt,
@@ -64,7 +64,7 @@ def add_ns_context(
64
64
  ctx_data: pd.DataFrame,
65
65
  ) -> pd.DataFrame:
66
66
  context_tables = schema.get_context_tables(tgt)
67
- ctx_tgt_nodes, ctx_tgt_path = get_table_chain_to_tgt(
67
+ _ctx_tgt_nodes, ctx_tgt_path = get_table_chain_to_tgt(
68
68
  schema=schema,
69
69
  tables=context_tables,
70
70
  tgt=tgt,
@@ -96,11 +96,11 @@ def add_ns_context(
96
96
  def add_previous_values_ctx(group):
97
97
  # due to lack of NAs support for int*, float*, bool in numpy, fillna was added
98
98
  group_ser = (
99
- group[cur_name].fillna(0)
100
- if any(dtype in str(cur_dtype) for dtype in ["int", "float", "bool"])
101
- else group[cur_name]
99
+ group[cur_name].fillna(0) # noqa: B023
100
+ if any(dtype in str(cur_dtype) for dtype in ["int", "float", "bool"]) # noqa: B023
101
+ else group[cur_name] # noqa: B023
102
102
  )
103
- group[prev_name] = [np.array(group_ser.values[:i], dtype=cur_dtype) for i in range(len(group))]
103
+ group[prev_name] = [np.array(group_ser.values[:i], dtype=cur_dtype) for i in range(len(group))] # noqa: B023
104
104
  return group
105
105
 
106
106
  # create list of the previous values and insert that column adjacent to the current column
@@ -460,7 +460,7 @@ class SqlAlchemyContainer(DBContainer, abc.ABC):
460
460
  try:
461
461
  return pd.read_sql(sql, engine, dtype_backend="pyarrow")
462
462
  except sa.exc.SQLAlchemyError as e:
463
- _LOG.error(f"Error executing query: {str(e)}")
463
+ _LOG.error(f"Error executing query: {e!s}")
464
464
  raise
465
465
 
466
466
  def drop_all(self):
@@ -564,7 +564,7 @@ class SqlAlchemyContainer(DBContainer, abc.ABC):
564
564
  )
565
565
  return foreign_keys
566
566
 
567
- @lru_cache
567
+ @lru_cache # noqa: B019
568
568
  def get_foreign_keys(self, table_name: str):
569
569
  if self.foreign_keys:
570
570
  foreign_keys = [fk for fk in self.foreign_keys if fk.get("TABLE_NAME") == table_name]
@@ -599,13 +599,13 @@ class SqlAlchemyContainer(DBContainer, abc.ABC):
599
599
  if not prefix:
600
600
  # List the schemas
601
601
  self.update_dbschema(None)
602
- return sorted(list(set(self.all_schemas())))
602
+ return sorted(set(self.all_schemas()))
603
603
  else:
604
604
  prefix = prefix.rstrip(".") # remove trailing dot if present
605
605
  # List the tables of the provided schema named {prefix}
606
606
  self.update_dbschema(prefix)
607
- locations = [".".join([prefix, loc]) for loc in self.get_object_list()]
608
- return sorted(list(set(locations)))
607
+ locations = [f"{prefix}.{loc}" for loc in self.get_object_list()]
608
+ return sorted(set(locations))
609
609
 
610
610
  def update_dbschema(self, dbschema: str | None) -> None:
611
611
  """
@@ -929,7 +929,7 @@ class SqlAlchemyTable(DBTable, abc.ABC):
929
929
  if self.is_output:
930
930
  # output tables are assumed to be initially missing,
931
931
  # thus don't read any metadata for them
932
- return None
932
+ return
933
933
 
934
934
  if item == "columns":
935
935
  self.columns = [c.name for c in self._sa_table.columns]
@@ -147,7 +147,7 @@ class BigQueryContainer(SqlAlchemyContainer):
147
147
  try:
148
148
  rows = self.client.query(query).result() # Waits for query to finish
149
149
  return [dict(row) for row in rows]
150
- except Exception:
150
+ except Exception: # noqa: BLE001
151
151
  _LOG.debug(f"Error while executing {query=}")
152
152
  return []
153
153
 
@@ -170,7 +170,7 @@ class BigQueryContainer(SqlAlchemyContainer):
170
170
  try:
171
171
  rows = self.client.query(query).result() # Waits for query to finish
172
172
  return next((row["COLUMN_NAME"] for row in rows), None)
173
- except Exception:
173
+ except Exception: # noqa: BLE001
174
174
  _LOG.debug(f"Error while executing {query=}")
175
175
  return None
176
176
 
@@ -111,7 +111,7 @@ class MssqlContainer(SqlAlchemyContainer):
111
111
  else:
112
112
  db_exist = False
113
113
  return db_exist
114
- except Exception:
114
+ except Exception: # noqa: BLE001
115
115
  return False
116
116
 
117
117
 
@@ -21,10 +21,10 @@ import numpy as np
21
21
  import oracledb
22
22
  import pandas as pd
23
23
  import sqlalchemy as sa
24
- import sqlalchemy.dialects.oracle as oracle
25
24
  import sqlalchemy.dialects.oracle as sa_oracle
26
25
  from pandas.io.sql import SQLDatabase, SQLTable
27
26
  from sqlalchemy import text
27
+ from sqlalchemy.dialects import oracle
28
28
  from sqlalchemy.dialects.oracle.base import OracleDialect
29
29
 
30
30
  from mostlyai.sdk._data.db.base import DBDType, SqlAlchemyContainer, SqlAlchemyTable
@@ -91,7 +91,7 @@ class PostgresqlContainer(SqlAlchemyContainer):
91
91
  with self.init_sa_connection() as connection:
92
92
  result = connection.execute(sa.text(f"SELECT 1 FROM pg_database WHERE datname='{self.dbname}'"))
93
93
  return bool(result.rowcount)
94
- except Exception as e:
94
+ except Exception as e: # noqa: BLE001
95
95
  _LOG.error(f"Error when checking if database exists: {e}")
96
96
  return False
97
97
 
@@ -103,7 +103,7 @@ class DType(abc.ABC):
103
103
  return lossless_null_map.equals(coerced_null_map) and bool(
104
104
  all(lossless_data[~lossless_null_map] == coerced_data[~lossless_null_map])
105
105
  )
106
- except Exception as e:
106
+ except Exception as e: # noqa: BLE001
107
107
  _LOG.warning(f"encompasses failed for {type(self)=} and {data.dtype=}: {e}")
108
108
  return False # in case of a failure, be on the safer side
109
109
 
@@ -114,7 +114,7 @@ class DType(abc.ABC):
114
114
  def encompass_data(
115
115
  self,
116
116
  data: pd.Series,
117
- fallback_dtypes: list["DType"] = None,
117
+ fallback_dtypes: list["DType"] | None = None,
118
118
  is_last_fallback_always_valid: bool = True,
119
119
  ) -> "DType":
120
120
  """
@@ -160,7 +160,7 @@ class VirtualDType(DType, abc.ABC):
160
160
 
161
161
 
162
162
  class VirtualVarchar(VirtualDType):
163
- def __init__(self, length: int = None):
163
+ def __init__(self, length: int | None = None):
164
164
  self.length = length
165
165
 
166
166
  def coerce(self, data: pd.Series) -> pd.Series:
@@ -251,7 +251,7 @@ class WrappedDType(DType):
251
251
  elif isinstance(dtype, VirtualDType):
252
252
  return cls.from_virtual(dtype)
253
253
  else:
254
- raise ValueError(f"Unsupported dtype: {dtype}")
254
+ raise ValueError(f"Unsupported dtype: {dtype}") # noqa: TRY004
255
255
 
256
256
  @classmethod
257
257
  def from_dtypes(cls, dtypes: dict[str, DType]) -> dict[str, "WrappedDType"]:
@@ -332,7 +332,7 @@ def coerce_dtype_by_encoding(
332
332
  x = x.astype(STRING)
333
333
  elif encoding_type is None or encoding_type == ModelEncodingType.auto:
334
334
  # treat keys as strings
335
- if pd.api.types.is_float_dtype(x):
335
+ if pd.api.types.is_float_dtype(x): # noqa: SIM102
336
336
  # convert float values that represent whole numbers to integers
337
337
  if x.dropna().apply(lambda v: float(v).is_integer()).all():
338
338
  x = x.astype("Int64")
@@ -496,9 +496,7 @@ class PandasDType(WrappedDType):
496
496
  return cls(FLOAT64)
497
497
  elif isinstance(dtype, VirtualVarchar):
498
498
  return cls(STRING)
499
- elif isinstance(dtype, VirtualDatetime):
500
- return cls("datetime64[ns]")
501
- elif isinstance(dtype, VirtualTimestamp):
499
+ elif isinstance(dtype, (VirtualDatetime, VirtualTimestamp)):
502
500
  return cls("datetime64[ns]")
503
501
  else:
504
502
  raise NotImplementedError(f"handler for virtual {dtype=} is not specified")
@@ -511,17 +509,9 @@ class PandasDType(WrappedDType):
511
509
  return VirtualInteger()
512
510
  elif dtype.lower().startswith("float") or dtype.startswith("double"):
513
511
  return VirtualFloat()
514
- elif dtype.startswith("str"):
515
- return VirtualVarchar()
516
- elif dtype.startswith("binary"):
517
- return VirtualVarchar()
518
- elif dtype == "object":
519
- return VirtualVarchar()
520
- elif dtype == "category":
521
- return VirtualVarchar()
522
- elif dtype.startswith("null"):
512
+ elif dtype.startswith(("str", "binary", "null")) or dtype == "object" or dtype == "category":
523
513
  return VirtualVarchar()
524
- elif dtype.startswith("date") or dtype.startswith("time"):
514
+ elif dtype.startswith(("date", "time")):
525
515
  return VirtualTimestamp()
526
516
  else:
527
517
  _LOG.warning(f"no VirtualDtype found for {dtype}")
@@ -358,7 +358,7 @@ class FileDataTable(DataTable, abc.ABC):
358
358
  message = "File not found."
359
359
  _LOG.error(message)
360
360
  raise MostlyDataException(message)
361
- except Exception:
361
+ except Exception: # noqa: BLE001
362
362
  message = "Encountered an unknown error when reading the file."
363
363
  _LOG.error(message)
364
364
  raise MostlyDataException(message)
@@ -460,7 +460,7 @@ class FileContainer(DataContainer):
460
460
  if not self.path or not self.path.exists():
461
461
  return []
462
462
  elif self.path.is_dir():
463
- return sorted(list(self.path.glob("*")))
463
+ return sorted(self.path.glob("*"))
464
464
  else:
465
465
  return [self.path]
466
466
 
@@ -527,10 +527,10 @@ class FileContainer(DataContainer):
527
527
 
528
528
  return result
529
529
  except duckdb.IOException as e:
530
- _LOG.error(f"IO Error executing query: {str(e)}")
530
+ _LOG.error(f"IO Error executing query: {e!s}")
531
531
  raise
532
532
  except duckdb.Error as e:
533
- _LOG.error(f"DuckDB Error executing query: {str(e)}")
533
+ _LOG.error(f"DuckDB Error executing query: {e!s}")
534
534
  raise
535
535
 
536
536