Skip to content

Commit 2b45632

Browse files
author
Samson Gebre
committed
Update migration tool and update related documentation
1 parent fc590c2 commit 2b45632

7 files changed

Lines changed: 18 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- `QueryResult.__getitem__` — index access (`result[0]`) returns a `Record`; slice access (`result[1:5]`) returns a new `QueryResult` (#175)
1919
- `DataverseModel` structural `Protocol` (`models/protocol.py`) — implement on any entity class to enable typed integration with CRUD operations without specifying table names or serializing manually (#175)
2020
- `col()`, `raw()`, `QueryResult`, and `DataverseModel` exported from the top-level `PowerPlatform.Dataverse` package (#175)
21-
- v0→v1 migration tool: `tools/migrate_v0_to_v1.py` rewrites v0 call sites to the v1 API with `--dry-run` support; covers `create`, `update`, `delete`, `get`, `list`, `fetchxml`, and query builder patterns (#175)
21+
- v0→v1 migration tool: installed as the `dataverse-migrate` console script (also runnable via `python -m PowerPlatform.Dataverse.migration.migrate_v0_to_v1`); rewrites v0 call sites to the v1 API with `--dry-run` support; covers `create`, `update`, `delete`, `get`, `list`, `fetchxml`, and query builder patterns; requires the `[migration]` optional extra (`pip install PowerPlatform-Dataverse-Client[migration]`) (#175)
2222
- Migration tool now auto-rewrites `QueryBuilder.to_dataframe()``.execute().to_dataframe()` (inserts `.execute()` when receiver is a recognised builder chain); output improved with `[NEEDS-MANUAL]` label for files that have no auto-rewrites but require manual attention, and a trailing note on `[MIGRATED]` lines when manual items remain (#175)
2323

2424
### Changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ for page_num, page in enumerate(
450450
print(record["name"])
451451
```
452452

453-
> **Deprecation note:** `execute(by_page=True)` and `execute(by_page=False)` are deprecated and emit a `UserWarning`. Replace with `execute_pages()` (streaming) or plain `execute()` (eager). `QueryBuilder.to_dataframe()` is also deprecated; use `.execute().to_dataframe()` instead. The migration tool (`tools/migrate_v0_to_v1.py`) rewrites all of these automatically.
453+
> **Deprecation note:** `execute(by_page=True)` and `execute(by_page=False)` are deprecated and emit a `UserWarning`. Replace with `execute_pages()` (streaming) or plain `execute()` (eager). `QueryBuilder.to_dataframe()` is also deprecated; use `.execute().to_dataframe()` instead. The migration tool rewrites all of these automatically — install with `pip install PowerPlatform-Dataverse-Client[migration]` and run `dataverse-migrate path/to/your/scripts/` (or `python -m PowerPlatform.Dataverse.migration.migrate_v0_to_v1` for development checkouts).
454454
455455
**Record count** -- include `$count=true` in the request:
456456

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies = [
4040

4141
[project.scripts]
4242
dataverse-install-claude-skill = "PowerPlatform.Dataverse._skill_installer:main"
43-
dataverse-migrate = "tools.migrate_v0_to_v1:main"
43+
dataverse-migrate = "PowerPlatform.Dataverse.migration.migrate_v0_to_v1:main"
4444

4545
[project.optional-dependencies]
4646
dev = [
@@ -54,12 +54,12 @@ dev = [
5454
migration = ["libcst>=1.0.0"]
5555

5656
[tool.setuptools]
57-
package-dir = {"" = "src", "tools" = "tools"}
57+
package-dir = {"" = "src"}
5858
zip-safe = false
5959

6060
[tool.setuptools.packages.find]
61-
where = ["src", "."]
62-
include = ["PowerPlatform*", "tools"]
61+
where = ["src"]
62+
include = ["PowerPlatform*"]
6363
namespaces = false
6464

6565
[tool.setuptools.package-data]

tools/__init__.py renamed to src/PowerPlatform/Dataverse/migration/__init__.py

File renamed without changes.

tools/migrate_v0_to_v1.py renamed to src/PowerPlatform/Dataverse/migration/migrate_v0_to_v1.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
dataverse-migrate path/to/your/scripts/ --client-var=svc # if client is named 'svc'
1717
1818
# Or via module for development installs:
19-
python -m tools.migrate_v0_to_v1 path/to/your/scripts/
19+
python -m PowerPlatform.Dataverse.migration.migrate_v0_to_v1 path/to/your/scripts/
2020
2121
Transformations applied
2222
-----------------------
@@ -763,6 +763,10 @@ def _collect_targets(paths: List[str]) -> List[Path]:
763763

764764
def main(argv: Optional[List[str]] = None) -> int:
765765
args = sys.argv[1:] if argv is None else list(argv)
766+
if "--help" in args or "-h" in args:
767+
print(__doc__)
768+
print("\nUsage: dataverse-migrate [--dry-run] [--client-var=NAME] <path> [<path> ...]")
769+
return 0
766770
dry_run = "--dry-run" in args
767771
client_var = "client"
768772
remaining = []

tests/unit/test_migration_tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4-
"""Unit tests for tools/migrate_v0_to_v1.py.
4+
"""Unit tests for PowerPlatform/Dataverse/migration/migrate_v0_to_v1.py.
55
66
Covers:
77
- QueryBuilder.to_dataframe() -> .execute().to_dataframe() (auto-rewrite)
@@ -31,13 +31,13 @@
3131

3232

3333
def _migrate(source: str, *, client_var: str = "client") -> str:
34-
from tools.migrate_v0_to_v1 import migrate_source
34+
from PowerPlatform.Dataverse.migration.migrate_v0_to_v1 import migrate_source
3535

3636
return migrate_source(textwrap.dedent(source), client_var=client_var)
3737

3838

3939
def _find_manual(source: str, *, client_var: str = "client") -> list:
40-
from tools.migrate_v0_to_v1 import find_manual_patterns
40+
from PowerPlatform.Dataverse.migration.migrate_v0_to_v1 import find_manual_patterns
4141

4242
return find_manual_patterns(textwrap.dedent(source), client_var=client_var)
4343

tests/unit/test_phase4_ga.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,15 +505,15 @@ class TestCodemodByPage(unittest.TestCase):
505505
@classmethod
506506
def setUpClass(cls):
507507
try:
508-
from tools.migrate_v0_to_v1 import migrate_source
508+
from PowerPlatform.Dataverse.migration.migrate_v0_to_v1 import migrate_source
509509

510510
cls.migrate = staticmethod(migrate_source)
511511
except ImportError:
512512
cls.migrate = None
513513

514514
def setUp(self):
515515
if self.migrate is None:
516-
self.skipTest("libcst not installed or tools package not on path")
516+
self.skipTest("libcst not installed")
517517

518518
def test_execute_by_page_true_becomes_execute_pages(self):
519519
src = "result = builder.execute(by_page=True)\n"
@@ -573,15 +573,15 @@ class TestManualReviewFinder(unittest.TestCase):
573573
@classmethod
574574
def setUpClass(cls):
575575
try:
576-
from tools.migrate_v0_to_v1 import find_manual_patterns
576+
from PowerPlatform.Dataverse.migration.migrate_v0_to_v1 import find_manual_patterns
577577

578578
cls.find = staticmethod(find_manual_patterns)
579579
except ImportError:
580580
cls.find = None
581581

582582
def setUp(self):
583583
if self.find is None:
584-
self.skipTest("libcst not installed or tools package not on path")
584+
self.skipTest("libcst not installed")
585585

586586
def test_records_get_flagged(self):
587587
src = "result = client.records.get('account', record_id)\n"

0 commit comments

Comments
 (0)