Skip to content

Commit e139c8b

Browse files
committed
converting to camelCase
1 parent 61f676d commit e139c8b

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

dbldatagen/spec/__init__.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,42 @@
44
in a type-safe, declarative way.
55
"""
66

7+
from typing import Any
8+
79
# Import only the compat layer by default to avoid triggering Spark/heavy dependencies
810
from .compat import BaseModel, Field, constr, root_validator, validator
911

12+
1013
# Lazy imports for heavy modules - import these explicitly when needed
1114
# from .column_spec import ColumnSpec
1215
# from .generator_spec import GeneratorSpec
1316
# from .generator_spec_impl import GeneratorSpecImpl
1417

1518
__all__ = [
1619
"BaseModel",
20+
"ColumnDefinition",
21+
"DatagenSpec",
1722
"Field",
23+
"Generator",
1824
"constr",
1925
"root_validator",
2026
"validator",
21-
"ColumnSpec",
22-
"GeneratorSpec",
23-
"GeneratorSpecImpl",
2427
]
2528

2629

27-
def __getattr__(name):
28-
"""Lazy import heavy modules to avoid triggering Spark initialization."""
30+
def __getattr__(name: str) -> Any: # noqa: ANN401
31+
"""Lazy import heavy modules to avoid triggering Spark initialization.
32+
33+
Note: Imports are intentionally inside this function to enable lazy loading
34+
and avoid importing heavy dependencies (pandas, IPython, Spark) until needed.
35+
"""
2936
if name == "ColumnSpec":
30-
from .column_spec import ColumnSpec
31-
return ColumnSpec
37+
from .column_spec import ColumnDefinition # noqa: PLC0415
38+
return ColumnDefinition
3239
elif name == "GeneratorSpec":
33-
from .generator_spec import GeneratorSpec
34-
return GeneratorSpec
40+
from .generator_spec import DatagenSpec # noqa: PLC0415
41+
return DatagenSpec
3542
elif name == "GeneratorSpecImpl":
36-
from .generator_spec_impl import GeneratorSpecImpl
37-
return GeneratorSpecImpl
43+
from .generator_spec_impl import Generator # noqa: PLC0415
44+
return Generator
3845
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
39-

dbldatagen/spec/generator_spec.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import Any, Literal, Union
4+
from typing import Any, Union
55

66
import pandas as pd
77
from IPython.display import HTML, display
88

99
from dbldatagen.spec.column_spec import ColumnDefinition
1010

11-
from .compat import BaseModel, validator
12-
from .output_targets import UCSchemaTarget, FilePathTarget
13-
14-
logger = logging.getLogger(__name__)
11+
from .compat import BaseModel
12+
from .output_targets import FilePathTarget, UCSchemaTarget
1513

1614

15+
logger = logging.getLogger(__name__)
1716

1817

1918
class TableDefinition(BaseModel):

dbldatagen/spec/generator_spec_impl.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, spark: SparkSession, app_name: str = "DataGen_ClassBased") ->
6060
self.app_name = app_name
6161
logger.info("Generator initialized with SparkSession")
6262

63-
def _columnspec_to_datagen_columnspec(self, col_def: ColumnDefinition) -> dict[str, Any]:
63+
def _columnSpecToDatagenColumnSpec(self, col_def: ColumnDefinition) -> dict[str, Any]:
6464
"""Convert a ColumnDefinition spec into dbldatagen DataGenerator column arguments.
6565
6666
This internal method translates the declarative ColumnDefinition format into the
@@ -124,7 +124,7 @@ def _columnspec_to_datagen_columnspec(self, col_def: ColumnDefinition) -> dict[s
124124

125125
return kwargs
126126

127-
def _prepare_data_generators(
127+
def _prepareDataGenerators(
128128
self,
129129
config: DatagenSpec,
130130
config_source_name: str = "PydanticConfig"
@@ -151,7 +151,7 @@ def _prepare_data_generators(
151151
:raises ValueError: If table configuration is invalid (should be caught by validate() first)
152152
153153
.. note::
154-
This is an internal method. Use generate_and_write_data() for the complete workflow
154+
This is an internal method. Use generateAndWriteData() for the complete workflow
155155
156156
.. note::
157157
Preparation is separate from building to allow inspection and modification of
@@ -188,7 +188,7 @@ def _prepare_data_generators(
188188

189189
# Process each column
190190
for col_def in table_spec.columns:
191-
kwargs = self._columnspec_to_datagen_columnspec(col_def)
191+
kwargs = self._columnSpecToDatagenColumnSpec(col_def)
192192
data_gen = data_gen.withColumn(colName=col_def.name, **kwargs)
193193
# Has performance implications.
194194

@@ -203,7 +203,7 @@ def _prepare_data_generators(
203203
logger.info("All data generators prepared successfully")
204204
return prepared_generators
205205

206-
def write_prepared_data(
206+
def writePreparedData(
207207
self,
208208
prepared_generators: dict[str, dg.DataGenerator],
209209
output_destination: Union[UCSchemaTarget, FilePathTarget, None],
@@ -224,7 +224,7 @@ def write_prepared_data(
224224
4. Logs row counts and write locations
225225
226226
:param prepared_generators: Dictionary mapping table names to DataGenerator objects
227-
(typically from _prepare_data_generators())
227+
(typically from _prepareDataGenerators())
228228
:param output_destination: Target location for output. Can be UCSchemaTarget,
229229
FilePathTarget, or None (no write, data generated only)
230230
:param config_source_name: Descriptive name for the config source, used in logging
@@ -275,7 +275,7 @@ def write_prepared_data(
275275
raise RuntimeError(f"Failed to write table '{table_name}': {e}") from e
276276
logger.info("All data writes completed successfully")
277277

278-
def generate_and_write_data(
278+
def generateAndWriteData(
279279
self,
280280
config: DatagenSpec,
281281
config_source_name: str = "PydanticConfig"
@@ -293,7 +293,7 @@ def generate_and_write_data(
293293
5. Logs progress and completion status
294294
295295
This method is the recommended entry point for most use cases. For more control over
296-
the generation process, use _prepare_data_generators() and write_prepared_data() separately.
296+
the generation process, use _prepareDataGenerators() and writePreparedData() separately.
297297
298298
:param config: DatagenSpec object defining tables, columns, and output destination.
299299
Should be validated with config.validate() before calling this method
@@ -317,21 +317,21 @@ def generate_and_write_data(
317317
... )
318318
>>> spec.validate() # Check for errors first
319319
>>> generator = Generator(spark)
320-
>>> generator.generate_and_write_data(spec)
320+
>>> generator.generateAndWriteData(spec)
321321
"""
322322
logger.info(f"Starting combined data generation and writing for {len(config.tables)} tables")
323323

324324
try:
325325
# Phase 1: Prepare data generators
326-
prepared_generators_map = self._prepare_data_generators(config, config_source_name)
326+
prepared_generators_map = self._prepareDataGenerators(config, config_source_name)
327327

328328
if not prepared_generators_map and list(config.tables.keys()):
329329
logger.warning(
330330
"No data generators were successfully prepared, though tables were defined")
331331
return
332332

333333
# Phase 2: Write data
334-
self.write_prepared_data(
334+
self.writePreparedData(
335335
prepared_generators_map,
336336
config.output_destination,
337337
config_source_name

dbldatagen/spec/output_targets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from .compat import BaseModel, validator
2-
from typing import Literal
31
import logging
2+
from typing import Literal
3+
4+
from .compat import BaseModel, validator
5+
46

57
logger = logging.getLogger(__name__)
68

0 commit comments

Comments
 (0)