-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path__init__.py
More file actions
225 lines (195 loc) · 5.22 KB
/
__init__.py
File metadata and controls
225 lines (195 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
"""Fiddler Utils - Admin Automation Library
This package provides high-level abstractions and utilities for common
Fiddler administrative tasks, reducing code duplication across utility
scripts and notebooks.
Designed for both Fiddler field engineers and customers. NOT part of
the official Fiddler SDK, but customers are welcome to use and extend it.
Version compatibility: Requires fiddler-client >= 3.10.0
Example:
```python
from fiddler_utils import get_or_init
from fiddler_utils import SchemaValidator, fql
# Initialize connection
get_or_init(url='https://acme.cloud.fiddler.ai', token='abc123')
# Extract columns from FQL expression
columns = fql.extract_columns('"age" > 30 and "status" == \'active\'')
# Validate schema compatibility
is_valid, missing = SchemaValidator.validate_columns(
columns, target_model
)
```
"""
import logging
__version__ = '0.1.0'
__author__ = 'Fiddler AI'
# Configure package-level logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler()) # Allow users to configure logging
# Import public API - Connection utilities
from .connection import (
get_or_init,
reset_connection,
connection_context,
ConnectionManager,
)
# Import public API - Schema validation
from .schema import (
SchemaValidator,
SchemaComparison,
ColumnInfo,
ColumnRole,
)
# Import public API - FQL utilities (as module)
from . import fql
# Import public API - Asset managers
from .assets import (
SegmentManager,
CustomMetricManager,
AlertManager,
ChartManager,
DashboardManager,
ModelManager,
BaselineManager,
FeatureImpactManager,
AssetExportData,
ImportResult,
ValidationResult,
ModelExportData,
ColumnExportData,
)
# Import public API - Project and environment management
from .projects import (
ProjectManager,
EnvironmentHierarchy,
ProjectInfo,
ModelInfo,
EnvironmentStats,
TimestampAnalysis,
)
# Import public API - Environment reporting
from .reporting import EnvironmentReporter
# Import public API - Safe iteration utilities
from .iteration import (
iterate_projects_safe,
iterate_models_safe,
count_models_by_project,
)
# Import public API - Model comparison
from .comparison import (
ModelComparator,
ComparisonResult,
ComparisonConfig,
ConfigurationComparison,
SpecComparison,
AssetComparison,
ValueDifference,
)
# Import public API - Exceptions
from .exceptions import (
FiddlerUtilsError,
ConnectionError,
ValidationError,
SchemaValidationError,
FQLError,
AssetNotFoundError,
AssetImportError,
BulkOperationError,
)
# Define public API
__all__ = [
# Version
'__version__',
# Logging utilities
'configure_logging',
# Connection utilities
'get_or_init',
'reset_connection',
'connection_context',
'ConnectionManager',
# Schema validation
'SchemaValidator',
'SchemaComparison',
'ColumnInfo',
'ColumnRole',
# FQL module
'fql',
# Asset managers
'SegmentManager',
'CustomMetricManager',
'AlertManager',
'ChartManager',
'DashboardManager',
'ModelManager',
'BaselineManager',
'FeatureImpactManager',
'AssetExportData',
'ImportResult',
'ValidationResult',
'ModelExportData',
'ColumnExportData',
# Project and environment management
'ProjectManager',
'EnvironmentHierarchy',
'ProjectInfo',
'ModelInfo',
'EnvironmentStats',
'TimestampAnalysis',
# Environment reporting
'EnvironmentReporter',
# Safe iteration utilities
'iterate_projects_safe',
'iterate_models_safe',
'count_models_by_project',
# Model comparison
'ModelComparator',
'ComparisonResult',
'ComparisonConfig',
'ConfigurationComparison',
'SpecComparison',
'AssetComparison',
'ValueDifference',
# Exceptions
'FiddlerUtilsError',
'ConnectionError',
'ValidationError',
'SchemaValidationError',
'FQLError',
'AssetNotFoundError',
'AssetImportError',
'BulkOperationError',
]
def configure_logging(
level: str = 'INFO',
format: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers: list = None,
):
"""Configure logging for fiddler_utils package.
Args:
level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
format: Log message format
handlers: Optional list of logging handlers
Example:
```python
from fiddler_utils import configure_logging
# Enable debug logging
configure_logging(level='DEBUG')
# Custom format
configure_logging(
level='INFO',
format='%(levelname)s - %(message)s'
)
```
"""
logger = logging.getLogger(__name__)
logger.setLevel(getattr(logging, level.upper()))
# Remove existing handlers
logger.handlers.clear()
if handlers:
for handler in handlers:
logger.addHandler(handler)
else:
# Add default console handler
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(format))
logger.addHandler(handler)
logger.info(f'Fiddler Utils logging configured at {level} level')