chore: update HF card citation copy and add library version to builder config#303
Conversation
Greptile OverviewGreptile SummaryAdds
|
| Filename | Overview |
|---|---|
| packages/data-designer-config/src/data_designer/config/version.py | New utility function centralizes version lookup with fallback handling |
| packages/data-designer-config/src/data_designer/config/config_builder.py | Added library_version computed field using centralized utility |
| packages/data-designer-engine/src/data_designer/engine/dataset_builders/column_wise_builder.py | Refactored to use centralized get_library_version() utility for telemetry |
Sequence Diagram
sequenceDiagram
participant User
participant ConfigBuilder as DataDesignerConfigBuilder
participant BuilderConfig
participant VersionUtil as get_library_version()
participant ImportLib as importlib.metadata
participant ColumnWiseBuilder as ColumnWiseDatasetBuilder
participant Telemetry as TelemetryHandler
Note over User,Telemetry: Configuration Export Flow
User->>ConfigBuilder: get_builder_config()
ConfigBuilder->>BuilderConfig: instantiate BuilderConfig
BuilderConfig->>VersionUtil: @computed_field library_version()
VersionUtil->>ImportLib: version("data-designer-config")
alt Package metadata available
ImportLib-->>VersionUtil: "1.2.3"
else PackageNotFoundError
ImportLib-->>VersionUtil: PackageNotFoundError
VersionUtil->>VersionUtil: return "unknown"
end
VersionUtil-->>BuilderConfig: version string
BuilderConfig-->>ConfigBuilder: BuilderConfig with library_version
ConfigBuilder-->>User: BuilderConfig (includes library_version in serialization)
Note over User,Telemetry: Telemetry Flow
User->>ColumnWiseBuilder: initialize with config
ColumnWiseBuilder->>VersionUtil: _CLIENT_VERSION = get_library_version()
VersionUtil->>ImportLib: version("data-designer-config")
alt Package metadata available
ImportLib-->>VersionUtil: "1.2.3"
else PackageNotFoundError
ImportLib-->>VersionUtil: PackageNotFoundError
VersionUtil->>VersionUtil: return "unknown"
end
VersionUtil-->>ColumnWiseBuilder: version string
ColumnWiseBuilder->>Telemetry: send events with _CLIENT_VERSION
Telemetry-->>ColumnWiseBuilder: telemetry recorded
| @computed_field | ||
| def library_version(self) -> str: | ||
| return importlib.metadata.version("data-designer-config") |
There was a problem hiding this comment.
Uncaught PackageNotFoundError
library_version calls importlib.metadata.version("data-designer-config") directly. If this code is executed from a source checkout or any environment where the data-designer-config distribution metadata isn’t present (no installed wheel / missing dist-info / different distribution name), accessing builder_config.library_version (and therefore BuilderConfig.model_dump() / to_json() / to_yaml()) will raise PackageNotFoundError and break config export/serialization.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/data-designer-config/src/data_designer/config/config_builder.py
Line: 69:71
Comment:
**Uncaught PackageNotFoundError**
`library_version` calls `importlib.metadata.version("data-designer-config")` directly. If this code is executed from a source checkout or any environment where the `data-designer-config` *distribution metadata* isn’t present (no installed wheel / missing dist-info / different distribution name), accessing `builder_config.library_version` (and therefore `BuilderConfig.model_dump()` / `to_json()` / `to_yaml()`) will raise `PackageNotFoundError` and break config export/serialization.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
This is a good call out. Should we wrap this in a try-catch?
There was a problem hiding this comment.
Yes, wrapping in a try-catch is the right approach. Return a fallback value (e.g., "unknown" or "dev") when the package metadata isn't available:
| @computed_field | |
| def library_version(self) -> str: | |
| return importlib.metadata.version("data-designer-config") | |
| @computed_field | |
| def library_version(self) -> str: | |
| try: | |
| return importlib.metadata.version("data-designer-config") | |
| except importlib.metadata.PackageNotFoundError: | |
| return "unknown" |
This ensures serialization won't break in development/source installations while still providing version info in production environments.
There was a problem hiding this comment.
I also wonder if it's worth centralizing this in a utility. We have telemetry depending on the same functionality.
There was a problem hiding this comment.
Good idea. Centralizing avoids duplication and ensures consistent version resolution across telemetry, config exports, and any future use cases.
Suggested approach:
- Create a utility in a shared module (e.g.,
packages/data-designer-config/src/data_designer/config/version.py):
import importlib.metadata
def get_library_version() -> str:
"""Get the installed library version, or 'dev' if not available."""
try:
return importlib.metadata.version("data-designer-config")
except importlib.metadata.PackageNotFoundError:
return "dev"- Use it in
BuilderConfig:
@computed_field
def library_version(self) -> str:
return get_library_version()- Update telemetry to use the same utility instead of its own version lookup.
This keeps the fallback logic in one place and makes it easy to change the fallback value or package name if needed.
Extract version retrieval into a dedicated version.py module with graceful error handling (returns "unknown" if package not found). Replace direct importlib.metadata.version() calls in config_builder and column_wise_builder with the new helper. Co-authored-by: Cursor <cursoragent@cursor.com>
72b0d57 to
386df11
Compare
📋 Summary
Updates the Hugging Face dataset card template with citation guidance and adds a
library_versioncomputed field toBuilderConfigso generated configs include the library version for traceability.🔄 Changes
✨ Added
library_versioncomputed field onBuilderConfigusingimportlib.metadata(06f8afb, 92555a6)library_versionfield serialization and correctness🔧 Changed
🤖 Generated with AI
Made with Cursor