-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize data version control for managing test images (#1036)
Using a data version control package called [`dvc`](https://github.com/iterative/dvc) to manage the PNG test images in the PyGMT repo! In a nutshell, store only the hash of the PNG on GitHub (in a *.png.dvc file), while having the actual PNG stored on DAGsHub at https://dagshub.com/GenericMappingTools/pygmt. * Initialize data version control Adding dvc package to environment.yml and running `dvc init` to get the barebones .dvcignore, .dvc/config & .dvc/.gitignore files. * Set dvc remote as https://dagshub.com/GenericMappingTools/pygmt.dvc * Temporarily installing dvc using pip instead of conda to make CI work * Refactor test_logo to use mpl_image_compare and track png files in dvc * Add dvc pull as a step in ci_tests.yaml to pull in data * List files in pygmt/tests/baseline/ to see what happens after dvc pull * Do `dvc pull` before `pip install dist/*` otherwise test PNGs aren't there * First draft of instructions for using dvc to store baseline images * Instruct to do `git push` first and then `dvc push` Technically the order shouldn't matter, but most tutorials seem to use `git push` first so follow that. * New checklist item for maintainers to get added to DAGsHub dvc remote * Move pygmt/tests/baseline/.gitignore to top-level * Clarify that `git rm -r --cached` only needs to run during migration * Try installing dvc from conda again now that there is a Py3.9 package * Install dvc and do `dvc pull` on GMT dev tests too * Refactor test_logo tests to be simpler and more unit-test like * Mention dvc status command to see which files need staging * Update test_image to use SI units and long aliases Co-authored-by: Dongdong Tian <[email protected]>
- Loading branch information
Showing
17 changed files
with
127 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/config.local | ||
/tmp | ||
/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[core] | ||
remote = upstream | ||
['remote "upstream"'] | ||
url = https://dagshub.com/GenericMappingTools/pygmt.dvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Add patterns of files dvc should ignore, which could improve | ||
# the performance. Learn more at | ||
# https://dvc.org/doc/user-guide/dvcignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,6 @@ doc/tutorials/ | |
|
||
# macOS | ||
.DS_Store | ||
|
||
# Data files (tracked using dvc) | ||
pygmt/tests/baseline/test_*.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ dependencies: | |
- codecov | ||
- coverage[toml] | ||
- docformatter | ||
- dvc | ||
- flake8 | ||
- ipython | ||
- isort>=5 | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: de86468aa453b14912c8362c67e51064 | ||
size: 10403 | ||
path: test_image.png |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 905d5b9f0f8d8b809899dfe9e87d0e91 | ||
size: 33347 | ||
path: test_logo.png |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 409119aeeec2680d106e32527009c255 | ||
size: 77366 | ||
path: test_logo_on_a_map.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
""" | ||
Tests for fig.logo. | ||
""" | ||
import pytest | ||
from pygmt import Figure | ||
from pygmt.helpers.testing import check_figures_equal | ||
|
||
|
||
@check_figures_equal() | ||
@pytest.mark.mpl_image_compare | ||
def test_logo(): | ||
""" | ||
Plot a GMT logo of a 2 inch width as a stand-alone plot. | ||
Plot the GMT logo as a stand-alone plot. | ||
""" | ||
fig_ref, fig_test = Figure(), Figure() | ||
# Use single-character arguments for the reference image | ||
fig_ref.logo(D="x0/0+w2i") | ||
fig_test.logo(position="x0/0+w2i") | ||
return fig_ref, fig_test | ||
fig = Figure() | ||
fig.logo() | ||
return fig | ||
|
||
|
||
@check_figures_equal() | ||
@pytest.mark.mpl_image_compare | ||
def test_logo_on_a_map(): | ||
""" | ||
Plot a GMT logo in the upper right corner of a map. | ||
Plot the GMT logo at the upper right corner of a map. | ||
""" | ||
fig_ref, fig_test = Figure(), Figure() | ||
# Use single-character arguments for the reference image | ||
fig_ref.coast(R="-90/-70/0/20", J="M6i", G="chocolate", B="") | ||
fig_ref.logo(D="jTR+o0.1i/0.1i+w3i", F="") | ||
|
||
fig_test.coast( | ||
region=[-90, -70, 0, 20], projection="M6i", land="chocolate", frame=True | ||
) | ||
fig_test.logo(position="jTR+o0.1i/0.1i+w3i", box=True) | ||
return fig_ref, fig_test | ||
fig = Figure() | ||
fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True) | ||
fig.logo(position="jTR+o0.25c/0.25c+w7.5c", box=True) | ||
return fig |