metabase-migration-toolkit 1.0.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 (44) hide show
  1. metabase_migration_toolkit-1.0.3/.env.example +42 -0
  2. metabase_migration_toolkit-1.0.3/CHANGELOG.md +43 -0
  3. metabase_migration_toolkit-1.0.3/CONTRIBUTING.md +397 -0
  4. metabase_migration_toolkit-1.0.3/LICENSE +22 -0
  5. metabase_migration_toolkit-1.0.3/MANIFEST.in +37 -0
  6. metabase_migration_toolkit-1.0.3/PKG-INFO +205 -0
  7. metabase_migration_toolkit-1.0.3/README.md +158 -0
  8. metabase_migration_toolkit-1.0.3/SECURITY.md +181 -0
  9. metabase_migration_toolkit-1.0.3/db_map.example.json +13 -0
  10. metabase_migration_toolkit-1.0.3/export_metabase.py +466 -0
  11. metabase_migration_toolkit-1.0.3/import_metabase.py +986 -0
  12. metabase_migration_toolkit-1.0.3/lib/__init__.py +40 -0
  13. metabase_migration_toolkit-1.0.3/lib/client.py +263 -0
  14. metabase_migration_toolkit-1.0.3/lib/config.py +181 -0
  15. metabase_migration_toolkit-1.0.3/lib/models.py +175 -0
  16. metabase_migration_toolkit-1.0.3/lib/py.typed +0 -0
  17. metabase_migration_toolkit-1.0.3/lib/utils.py +167 -0
  18. metabase_migration_toolkit-1.0.3/metabase_migration_toolkit.egg-info/PKG-INFO +205 -0
  19. metabase_migration_toolkit-1.0.3/metabase_migration_toolkit.egg-info/SOURCES.txt +42 -0
  20. metabase_migration_toolkit-1.0.3/metabase_migration_toolkit.egg-info/dependency_links.txt +1 -0
  21. metabase_migration_toolkit-1.0.3/metabase_migration_toolkit.egg-info/entry_points.txt +3 -0
  22. metabase_migration_toolkit-1.0.3/metabase_migration_toolkit.egg-info/requires.txt +19 -0
  23. metabase_migration_toolkit-1.0.3/metabase_migration_toolkit.egg-info/top_level.txt +3 -0
  24. metabase_migration_toolkit-1.0.3/pyproject.toml +221 -0
  25. metabase_migration_toolkit-1.0.3/requirements.txt +4 -0
  26. metabase_migration_toolkit-1.0.3/setup.cfg +4 -0
  27. metabase_migration_toolkit-1.0.3/setup.py +10 -0
  28. metabase_migration_toolkit-1.0.3/tests/__init__.py +6 -0
  29. metabase_migration_toolkit-1.0.3/tests/conftest.py +259 -0
  30. metabase_migration_toolkit-1.0.3/tests/fixtures/__init__.py +5 -0
  31. metabase_migration_toolkit-1.0.3/tests/fixtures/sample_responses.py +182 -0
  32. metabase_migration_toolkit-1.0.3/tests/integration/__init__.py +12 -0
  33. metabase_migration_toolkit-1.0.3/tests/integration/test_cli_options.py +1304 -0
  34. metabase_migration_toolkit-1.0.3/tests/integration/test_e2e_export_import.py +528 -0
  35. metabase_migration_toolkit-1.0.3/tests/integration/test_export_import_flow.py +101 -0
  36. metabase_migration_toolkit-1.0.3/tests/integration/test_helpers.py +445 -0
  37. metabase_migration_toolkit-1.0.3/tests/test_client.py +307 -0
  38. metabase_migration_toolkit-1.0.3/tests/test_config.py +305 -0
  39. metabase_migration_toolkit-1.0.3/tests/test_dependency_resolution.py +334 -0
  40. metabase_migration_toolkit-1.0.3/tests/test_error_handling.py +350 -0
  41. metabase_migration_toolkit-1.0.3/tests/test_export.py +306 -0
  42. metabase_migration_toolkit-1.0.3/tests/test_import.py +375 -0
  43. metabase_migration_toolkit-1.0.3/tests/test_models.py +348 -0
  44. metabase_migration_toolkit-1.0.3/tests/test_utils.py +339 -0
@@ -0,0 +1,42 @@
1
+ # Metabase Migration Toolkit - Environment Variables
2
+ # Copy this file to .env and fill in your credentials
3
+
4
+ # ============================================
5
+ # SOURCE METABASE (for export)
6
+ # ============================================
7
+
8
+ # Source Metabase URL
9
+ MB_SOURCE_URL=https://your-source-metabase.com
10
+
11
+ # Authentication - choose ONE method:
12
+
13
+ # Option 1: Username and Password
14
+ MB_SOURCE_USERNAME=your_username@example.com
15
+ MB_SOURCE_PASSWORD=your_password
16
+
17
+ # Option 2: Session Token (from browser cookies)
18
+ # MB_SOURCE_SESSION_TOKEN=your_session_token
19
+
20
+ # Option 3: Personal API Token (recommended for automation)
21
+ # MB_SOURCE_PERSONAL_TOKEN=your_api_token
22
+
23
+
24
+ # ============================================
25
+ # TARGET METABASE (for import)
26
+ # ============================================
27
+
28
+ # Target Metabase URL
29
+ MB_TARGET_URL=https://your-target-metabase.com
30
+
31
+ # Authentication - choose ONE method:
32
+
33
+ # Option 1: Username and Password
34
+ MB_TARGET_USERNAME=your_username@example.com
35
+ MB_TARGET_PASSWORD=your_password
36
+
37
+ # Option 2: Session Token (from browser cookies)
38
+ # MB_TARGET_SESSION_TOKEN=your_session_token
39
+
40
+ # Option 3: Personal API Token (recommended for automation)
41
+ # MB_TARGET_PERSONAL_TOKEN=your_api_token
42
+
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Preparing for initial PyPI release
12
+ - Comprehensive test suite
13
+ - CI/CD pipeline with GitHub Actions
14
+ - Code quality tools (black, ruff, mypy)
15
+ - Community guidelines and contribution documentation
16
+
17
+ ## [1.0.0] - 2025-10-07
18
+
19
+ ### Added
20
+ - Initial release of Metabase Migration Toolkit
21
+ - Export Metabase collections, cards (questions), and dashboards
22
+ - Import with intelligent database remapping
23
+ - Recursive dependency resolution for cards
24
+ - Conflict resolution strategies (skip, overwrite, rename)
25
+ - Dry-run mode for safe preview of import actions
26
+ - Comprehensive structured logging with configurable levels
27
+ - Retry logic with exponential backoff for API requests
28
+ - Multiple authentication methods (username/password, session token, personal token)
29
+ - Environment variable support via .env files
30
+ - Progress bars for long-running operations
31
+ - Manifest file generation for export tracking
32
+ - Collection hierarchy preservation
33
+ - Support for archived items (optional inclusion)
34
+ - Selective export by root collection IDs
35
+
36
+ ### Security
37
+ - Credentials handled securely via environment variables
38
+ - Passwords and tokens masked in logs and export files
39
+ - No sensitive data exposed in error messages
40
+
41
+ [Unreleased]: https://github.com/yourusername/metabase-migration-toolkit/compare/v1.0.0...HEAD
42
+ [1.0.0]: https://github.com/yourusername/metabase-migration-toolkit/releases/tag/v1.0.0
43
+
@@ -0,0 +1,397 @@
1
+ # Contributing to Metabase Migration Toolkit
2
+
3
+ Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Code of Conduct](#code-of-conduct)
8
+ - [Getting Started](#getting-started)
9
+ - [Development Setup](#development-setup)
10
+ - [Code Quality Standards](#code-quality-standards)
11
+ - [Testing Guidelines](#testing-guidelines)
12
+ - [Submitting Changes](#submitting-changes)
13
+ - [Release Process](#release-process)
14
+
15
+ ## Code of Conduct
16
+
17
+ This project adheres to a Code of Conduct that all contributors are expected to follow. Please read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before contributing.
18
+
19
+ ## Getting Started
20
+
21
+ ### Prerequisites
22
+
23
+ - Python 3.8 or higher (3.11 recommended for development)
24
+ - Git
25
+ - pip and virtualenv (or similar)
26
+
27
+ ### Finding Issues to Work On
28
+
29
+ - Check the [Issues](https://github.com/YOUR_USERNAME/metabase-migration-toolkit/issues) page
30
+ - Look for issues labeled `good first issue` or `help wanted`
31
+ - Comment on an issue to let others know you're working on it
32
+
33
+ ## Development Setup
34
+
35
+ ### 1. Fork and Clone
36
+
37
+ ```bash
38
+ # Fork the repository on GitHub, then clone your fork
39
+ git clone https://github.com/YOUR_USERNAME/metabase-migration-toolkit.git
40
+ cd metabase-migration-toolkit
41
+
42
+ # Add upstream remote
43
+ git remote add upstream https://github.com/ORIGINAL_OWNER/metabase-migration-toolkit.git
44
+ ```
45
+
46
+ ### 2. Create a Virtual Environment
47
+
48
+ ```bash
49
+ # Create virtual environment
50
+ python -m venv venv
51
+
52
+ # Activate it
53
+ source venv/bin/activate # On Windows: venv\Scripts\activate
54
+ ```
55
+
56
+ ### 3. Install Development Dependencies
57
+
58
+ ```bash
59
+ # Install package with development dependencies
60
+ make install-dev
61
+
62
+ # Or manually:
63
+ pip install -e ".[dev]"
64
+ pre-commit install
65
+ ```
66
+
67
+ ### 4. Verify Setup
68
+
69
+ ```bash
70
+ # Run tests
71
+ make test
72
+
73
+ # Run all quality checks
74
+ make quality
75
+ ```
76
+
77
+ ## Code Quality Standards
78
+
79
+ We maintain high code quality standards using automated tools. All code must pass these checks before being merged.
80
+
81
+ ### Code Formatting
82
+
83
+ We use **Black** for code formatting with a line length of 100 characters.
84
+
85
+ ```bash
86
+ # Format code
87
+ make format
88
+
89
+ # Check formatting
90
+ black --check lib/ tests/ *.py
91
+ ```
92
+
93
+ **Configuration:** See `pyproject.toml` for Black settings.
94
+
95
+ ### Import Sorting
96
+
97
+ We use **isort** to sort imports, configured to be compatible with Black.
98
+
99
+ ```bash
100
+ # Sort imports
101
+ isort lib/ tests/ *.py
102
+
103
+ # Check import sorting
104
+ isort --check-only lib/ tests/ *.py
105
+ ```
106
+
107
+ ### Linting
108
+
109
+ We use **Ruff** for fast Python linting.
110
+
111
+ ```bash
112
+ # Run linter
113
+ make lint
114
+
115
+ # Auto-fix issues
116
+ ruff check --fix lib/ tests/ *.py
117
+ ```
118
+
119
+ **Configuration:** See `pyproject.toml` for Ruff settings.
120
+
121
+ ### Type Checking
122
+
123
+ We use **Mypy** for static type checking.
124
+
125
+ ```bash
126
+ # Run type checker
127
+ make type-check
128
+
129
+ # Or directly
130
+ mypy lib/ --ignore-missing-imports
131
+ ```
132
+
133
+ **Guidelines:**
134
+ - Add type hints to all function signatures
135
+ - Use `Optional[T]` for nullable types
136
+ - Use `List[T]`, `Dict[K, V]`, etc. for collections
137
+ - Import types from `typing` module
138
+
139
+ ### Security Scanning
140
+
141
+ We use **Bandit** for security scanning.
142
+
143
+ ```bash
144
+ # Run security scan
145
+ make security
146
+
147
+ # Or directly
148
+ bandit -r lib/ -f screen
149
+ ```
150
+
151
+ ### Pre-commit Hooks
152
+
153
+ We use pre-commit hooks to automatically check code quality before commits.
154
+
155
+ ```bash
156
+ # Install hooks (done automatically with make install-dev)
157
+ pre-commit install
158
+
159
+ # Run hooks manually on all files
160
+ make pre-commit
161
+
162
+ # Update hooks
163
+ make pre-commit-update
164
+ ```
165
+
166
+ **Hooks include:**
167
+ - Trailing whitespace removal
168
+ - End-of-file fixer
169
+ - YAML/JSON/TOML validation
170
+ - Black formatting
171
+ - isort import sorting
172
+ - Ruff linting
173
+ - Mypy type checking
174
+ - Bandit security scanning
175
+ - Markdown linting
176
+ - Secret detection
177
+
178
+ ## Testing Guidelines
179
+
180
+ ### Writing Tests
181
+
182
+ - Place tests in the `tests/` directory
183
+ - Name test files `test_*.py`
184
+ - Name test functions `test_*`
185
+ - Use descriptive test names that explain what is being tested
186
+ - Follow the Arrange-Act-Assert pattern
187
+
188
+ **Example:**
189
+
190
+ ```python
191
+ def test_sanitize_filename_removes_special_characters():
192
+ """Test that sanitize_filename removes special characters."""
193
+ # Arrange
194
+ filename = "test/file:name*.txt"
195
+
196
+ # Act
197
+ result = sanitize_filename(filename)
198
+
199
+ # Assert
200
+ assert result == "test_file_name_.txt"
201
+ ```
202
+
203
+ ### Running Tests
204
+
205
+ ```bash
206
+ # Run all tests
207
+ make test
208
+
209
+ # Run with coverage
210
+ make test-cov
211
+
212
+ # Run specific test file
213
+ pytest tests/test_utils.py
214
+
215
+ # Run specific test
216
+ pytest tests/test_utils.py::test_sanitize_filename
217
+
218
+ # Run tests matching pattern
219
+ pytest -k "sanitize"
220
+ ```
221
+
222
+ ### Test Coverage
223
+
224
+ We aim for **80%+ test coverage**.
225
+
226
+ ```bash
227
+ # Generate coverage report
228
+ make test-cov
229
+
230
+ # View HTML report
231
+ open htmlcov/index.html
232
+ ```
233
+
234
+ ### Test Categories
235
+
236
+ Tests are marked with pytest markers:
237
+
238
+ - `@pytest.mark.integration` - Integration tests (require external services)
239
+ - `@pytest.mark.slow` - Slow tests (> 1 second)
240
+ - `@pytest.mark.requires_api` - Tests requiring API access
241
+
242
+ ```bash
243
+ # Skip slow tests
244
+ pytest -m "not slow"
245
+
246
+ # Run only integration tests
247
+ pytest -m integration
248
+ ```
249
+
250
+ ## Submitting Changes
251
+
252
+ ### 1. Create a Branch
253
+
254
+ ```bash
255
+ # Update your fork
256
+ git checkout main
257
+ git pull upstream main
258
+
259
+ # Create a feature branch
260
+ git checkout -b feature/your-feature-name
261
+ # or
262
+ git checkout -b fix/your-bug-fix
263
+ ```
264
+
265
+ ### 2. Make Changes
266
+
267
+ - Write clear, concise commit messages
268
+ - Keep commits focused and atomic
269
+ - Add tests for new functionality
270
+ - Update documentation as needed
271
+
272
+ ### 3. Run Quality Checks
273
+
274
+ ```bash
275
+ # Run all checks
276
+ make ci
277
+
278
+ # Or individually
279
+ make format # Format code
280
+ make lint # Run linters
281
+ make type-check # Type checking
282
+ make test-cov # Tests with coverage
283
+ ```
284
+
285
+ ### 4. Commit Changes
286
+
287
+ ```bash
288
+ # Stage changes
289
+ git add .
290
+
291
+ # Commit (pre-commit hooks will run automatically)
292
+ git commit -m "feat: add new feature"
293
+
294
+ # If pre-commit hooks fail, fix issues and commit again
295
+ ```
296
+
297
+ **Commit Message Format:**
298
+
299
+ We follow [Conventional Commits](https://www.conventionalcommits.org/):
300
+
301
+ - `feat:` - New feature
302
+ - `fix:` - Bug fix
303
+ - `docs:` - Documentation changes
304
+ - `style:` - Code style changes (formatting, etc.)
305
+ - `refactor:` - Code refactoring
306
+ - `test:` - Adding or updating tests
307
+ - `chore:` - Maintenance tasks
308
+ - `ci:` - CI/CD changes
309
+
310
+ ### 5. Push and Create Pull Request
311
+
312
+ ```bash
313
+ # Push to your fork
314
+ git push origin feature/your-feature-name
315
+
316
+ # Create a pull request on GitHub
317
+ ```
318
+
319
+ ### 6. Pull Request Guidelines
320
+
321
+ - Fill out the PR template completely
322
+ - Link related issues using `Fixes #123` or `Relates to #456`
323
+ - Ensure all CI checks pass
324
+ - Respond to review feedback promptly
325
+ - Keep PR scope focused and manageable
326
+
327
+ ## Code Review Process
328
+
329
+ 1. **Automated Checks**: All PRs must pass automated CI checks
330
+ 2. **Peer Review**: At least one maintainer must approve
331
+ 3. **Testing**: New features must include tests
332
+ 4. **Documentation**: Update docs for user-facing changes
333
+ 5. **Changelog**: Update CHANGELOG.md for notable changes
334
+
335
+ ## Release Process
336
+
337
+ Releases are managed by maintainers:
338
+
339
+ 1. Update version in `lib/__init__.py`
340
+ 2. Update `CHANGELOG.md`
341
+ 3. Create a GitHub release
342
+ 4. Package is automatically published to PyPI
343
+
344
+ ## Development Workflow Summary
345
+
346
+ ```bash
347
+ # 1. Setup (once)
348
+ make dev-setup
349
+
350
+ # 2. Create branch
351
+ git checkout -b feature/my-feature
352
+
353
+ # 3. Make changes and test
354
+ make test
355
+
356
+ # 4. Check code quality
357
+ make quality
358
+
359
+ # 5. Commit (pre-commit hooks run automatically)
360
+ git commit -m "feat: my feature"
361
+
362
+ # 6. Push and create PR
363
+ git push origin feature/my-feature
364
+ ```
365
+
366
+ ## Useful Make Commands
367
+
368
+ ```bash
369
+ make help # Show all available commands
370
+ make install-dev # Install with dev dependencies
371
+ make test # Run tests
372
+ make test-cov # Run tests with coverage
373
+ make lint # Run linters
374
+ make format # Format code
375
+ make type-check # Run type checker
376
+ make security # Run security checks
377
+ make quality # Run all quality checks
378
+ make pre-commit # Run pre-commit hooks
379
+ make build # Build package
380
+ make clean # Clean build artifacts
381
+ make ci # Run all CI checks locally
382
+ ```
383
+
384
+ ## Getting Help
385
+
386
+ - **Questions**: Open a [Discussion](https://github.com/YOUR_USERNAME/metabase-migration-toolkit/discussions)
387
+ - **Bugs**: Open an [Issue](https://github.com/YOUR_USERNAME/metabase-migration-toolkit/issues)
388
+ - **Security**: See [SECURITY.md](SECURITY.md)
389
+
390
+ ## License
391
+
392
+ By contributing, you agree that your contributions will be licensed under the MIT License.
393
+
394
+ ---
395
+
396
+ Thank you for contributing! 🎉
397
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Metabase Migration Toolkit Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,37 @@
1
+ # Include documentation
2
+ include README.md
3
+ include LICENSE
4
+ include CHANGELOG.md
5
+ include CONTRIBUTING.md
6
+ include CODE_OF_CONDUCT.md
7
+ include SECURITY.md
8
+
9
+ # Include configuration files
10
+ include pyproject.toml
11
+ include setup.py
12
+ include requirements.txt
13
+ include .env.example
14
+ include db_map.example.json
15
+
16
+ # Include source code
17
+ recursive-include lib *.py
18
+ recursive-include tests *.py
19
+
20
+ # Include documentation
21
+ recursive-include docs *.md *.rst *.txt
22
+
23
+ # Exclude unnecessary files
24
+ exclude .gitignore
25
+ exclude .pre-commit-config.yaml
26
+ recursive-exclude * __pycache__
27
+ recursive-exclude * *.py[co]
28
+ recursive-exclude * .DS_Store
29
+
30
+ # Exclude export data and temporary files
31
+ exclude metabase_export
32
+ exclude tmp
33
+ exclude db_map.json
34
+ exclude .env
35
+ recursive-exclude metabase_export *
36
+ recursive-exclude tmp *
37
+