Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kart diff [commit_id] returning error for commits containing changes from a deleted dataset. #611

Closed
Zumitify opened this issue Apr 24, 2022 · 1 comment · Fixed by #622

Comments

@Zumitify
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.
When we use kart diff <commit_id> to see the diff for commits that contains changes of a dataset that has been deleted from the repo (using kart data rm <dataset>, it returns an error trace and is not handled gracefully.

Output

E:\self_study\GSoC22\KART\kart_tutorial\buildings-project>kart diff 8501064c8
Traceback (most recent call last):
  File "C:\Users\ASUS\source\repos\kart\build\venv\Scripts\kart-script.py", line 33, in <module>
    sys.exit(load_entry_point('kart', 'console_scripts', 'kart')())
  File "c:\users\asus\source\repos\kart\kart\cli.py", line 352, in entrypoint
    cli()
  File "C:\Users\ASUS\source\repos\kart\build\venv\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\ASUS\source\repos\kart\build\venv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\asus\source\repos\kart\kart\cli.py", line 160, in invoke
    return super().invoke(ctx)
  File "C:\Users\ASUS\source\repos\kart\build\venv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\ASUS\source\repos\kart\build\venv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\ASUS\source\repos\kart\build\venv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\ASUS\source\repos\kart\build\venv\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\asus\source\repos\kart\kart\diff.py", line 175, in diff
    diff_writer.write_diff()
  File "c:\users\asus\source\repos\kart\kart\base_diff_writer.py", line 230, in write_diff
    self.has_changes |= self.write_ds_diff_for_path(ds_path)
  File "c:\users\asus\source\repos\kart\kart\base_diff_writer.py", line 235, in write_ds_diff_for_path
    ds_diff = self.get_dataset_diff(ds_path)
  File "c:\users\asus\source\repos\kart\kart\base_diff_writer.py", line 274, in get_dataset_diff
    ds_filter=self.repo_key_filter[ds_path],
  File "c:\users\asus\source\repos\kart\kart\diff_util.py", line 188, in get_dataset_diff
    target_wc_diff = target_ds.diff_to_wc(wc_diff_context, ds_filter=ds_filter)
AttributeError: 'NoneType' object has no attribute 'diff_to_wc'

Diff output before deleting the dataset greenspace :

E:\self_study\GSoC22\KART\kart_tutorial\buildings-project>kart diff 8501064c8
--- greenspace:feature:18751
+++ greenspace:feature:18751
-                         distinctiveName1 = Keswick Golf Club
+                         distinctiveName1 = Keswick Golf Club2
--- wellington_building_outlines:feature:4366
+++ wellington_building_outlines:feature:4366
-                                      use = Unknown
+                                      use = Rowhouse1
--- wellington_building_outlines:feature:4367
+++ wellington_building_outlines:feature:4367
-                                      use = Unknown
+                                      use = Rowhouse5
--- wellington_building_outlines:feature:56072
+++ wellington_building_outlines:feature:56072
-                                      use = Unknown
+                                      use = South of lshaped tower

To Reproduce

  1. Init a kart repo, with a dataset (say buildings-project.gpkg ) , make some changes, and commit it.
  2. Import+rename another table ( say opgrsp_gb.gpkg:GreenspaceSite to greenspace ) into the existing repository.
E:\self_study\GSoC22\KART\kart_tutorial\buildings-project>kart data ls
greenspace
wellington_building_outlines
  1. Make changes in the new dataset greenspace and commit them.
    Commit log:
8844a1283 (HEAD -> master) Added row houses 1 and 5
1a894dfa7 Edited greenspace to club2 and building to south lshape tower
8501064c8 Added west of lshaped tower
331600729 Added lshaped tower
191fc8dc0 Added south and northewestern tower
3b5d6926d Import from opgrsp_gb.gpkg:GreenspaceSite to greenspace/
418c3d92e Added stadium, northern and western tower
af6f0cac7 Import from wellington-building-outlines.gpkg:wellington_building_outlines to wellington_building_outlines/
  1. Delete the dataset greenspace using kart data rm greenspace command.
  2. Now kart diff <commit_id> for any commit after dataset greenspace addition i.e. commit id 3b5d6926d (except for HEAD) returns the above error trace. [Commit id's mentioned in ** commit_id **]
    Commit logs:
d9df5059e (HEAD -> master) Removing dataset greenspace
**8844a1283** Added row houses 1 and 5
**1a894dfa7** Edited greenspace to club2 and building to south lshape tower
**8501064c8** Added west of lshaped tower
**331600729** Added lshaped tower
**191fc8dc0** Added south and northewestern tower
**3b5d6926d** Import from opgrsp_gb.gpkg:GreenspaceSite to greenspace/
418c3d92e Added stadium, northern and western tower
af6f0cac7 Import from wellington-building-outlines.gpkg:wellington_building_outlines to wellington_building_outlines/

Expected behavior
kart diff <commit_id> should return the diff of the rest of the changes (of dataset wellington-building-outlines ) and not show an error trace for not finding the dataset greenspace.

Version Info

  • OS: [Windows 10]
  • Version:
E:\self_study\GSoC22\KART\kart_tutorial\buildings-project>kart --version
Kart v0.11.2.dev0, Copyright (c) Kart Contributors
» GDAL v3.3.2; PROJ v8.1.1
» PyGit2 v1.9.0; Libgit2 v1.4.2; Git v2.34.0.windows.1.13.g93318cbc8d
» SQLAlchemy v1.4.32; pysqlite3 v2.6.0/v3.31.1; SpatiaLite v5.0.0; Libpq v11.0.9
» SpatialIndex v1.9.3
@Zumitify
Copy link
Contributor Author

Additional information about the issue:

  1. Diff for subsequent commits are shown properly (commits after the dataset greenspace is deleted).
cd8025010 (HEAD -> master) Added row house garden
d9df5059e Removing dataset greenspace
8844a1283 Added row houses 1 and 5
.
.
E:\self_study\GSoC22\KART\kart_tutorial\buildings-project>kart diff d9df5059e
--- wellington_building_outlines:feature:4513
+++ wellington_building_outlines:feature:4513
-                                      use = Unknown
+                                      use = Row_house garden
  1. kart diff <commit_id1>...<commit_id2> works properly even after the dataset greenspace is deleted.
E:\self_study\GSoC22\KART\kart_tutorial\buildings-project>kart diff 8501064c8...8844a1283
--- greenspace:feature:18751
+++ greenspace:feature:18751
-                         distinctiveName1 = Keswick Golf Club
+                         distinctiveName1 = Keswick Golf Club2
--- wellington_building_outlines:feature:4366
+++ wellington_building_outlines:feature:4366
-                                      use = Unknown
+                                      use = Rowhouse1
--- wellington_building_outlines:feature:4367
+++ wellington_building_outlines:feature:4367
-                                      use = Unknown
+                                      use = Rowhouse5
--- wellington_building_outlines:feature:56072
+++ wellington_building_outlines:feature:56072
-                                      use = Unknown
+                                      use = South of lshaped tower

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant