From cff85bfd7c47a145d2cab702f03f9df5bd19010f Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 20 Apr 2021 19:45:12 -0400 Subject: [PATCH 1/3] Testing changes for added, changed, and deleted dvc files --- pygmt/tests/baseline/test_basemap_add.png.dvc | 4 ++++ pygmt/tests/baseline/test_basemap_compass.png.dvc | 4 ++-- pygmt/tests/baseline/test_basemap_map_scale.png.dvc | 4 ---- pygmt/tests/test_basemap.py | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 pygmt/tests/baseline/test_basemap_add.png.dvc delete mode 100644 pygmt/tests/baseline/test_basemap_map_scale.png.dvc diff --git a/pygmt/tests/baseline/test_basemap_add.png.dvc b/pygmt/tests/baseline/test_basemap_add.png.dvc new file mode 100644 index 00000000000..9400ed7cfff --- /dev/null +++ b/pygmt/tests/baseline/test_basemap_add.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 40ed35b2a39ff16ad7e3e90946adc7c5 + size: 5773 + path: test_basemap_add.png diff --git a/pygmt/tests/baseline/test_basemap_compass.png.dvc b/pygmt/tests/baseline/test_basemap_compass.png.dvc index 13c48fad715..7be2c24e2df 100644 --- a/pygmt/tests/baseline/test_basemap_compass.png.dvc +++ b/pygmt/tests/baseline/test_basemap_compass.png.dvc @@ -1,4 +1,4 @@ outs: -- md5: 5ecccc4123b28636b62e01f642006ae4 - size: 90778 +- md5: 1b7ed2d28e7a9521de014d95c0f7c29b + size: 47646 path: test_basemap_compass.png diff --git a/pygmt/tests/baseline/test_basemap_map_scale.png.dvc b/pygmt/tests/baseline/test_basemap_map_scale.png.dvc deleted file mode 100644 index b952b792c59..00000000000 --- a/pygmt/tests/baseline/test_basemap_map_scale.png.dvc +++ /dev/null @@ -1,4 +0,0 @@ -outs: -- md5: f1ff6ede343ce3d2fc42cbe9ef0ba96b - size: 40128 - path: test_basemap_map_scale.png diff --git a/pygmt/tests/test_basemap.py b/pygmt/tests/test_basemap.py index 726661ab165..cbfb65846af 100644 --- a/pygmt/tests/test_basemap.py +++ b/pygmt/tests/test_basemap.py @@ -92,7 +92,7 @@ def test_basemap_compass(): """ fig = Figure() fig.basemap( - region=[127.5, 128.5, 26, 27], + region=[120, 128.5, 26, 27], projection="H15c", frame=True, compass="jMC+w5c+d11.5", @@ -101,15 +101,14 @@ def test_basemap_compass(): @pytest.mark.mpl_image_compare -def test_basemap_map_scale(): +def test_basemap_add(): """ - Create a map with a map scale. + Create a map. """ fig = Figure() fig.basemap( - region=[127.5, 128.5, 26, 27], + region=[120, 128.5, 26, 27], projection="H15c", frame=True, - map_scale="jMC+c26.5+w10k+f+l", ) return fig From 7d14988c79ac7be284fc1544fe4bc484e7d39824 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 21 Apr 2021 01:00:30 -0400 Subject: [PATCH 2/3] Improve the DVC image diff workflow to support side-by-side comparison of modified images --- .github/workflows/dvc-diff.yml | 49 +++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dvc-diff.yml b/.github/workflows/dvc-diff.yml index 07da75674fd..feaa60f07e0 100644 --- a/.github/workflows/dvc-diff.yml +++ b/.github/workflows/dvc-diff.yml @@ -24,6 +24,9 @@ jobs: - name: Setup continuous machine learning (CML) uses: iterative/setup-cml@v1.0.0 + - name: Pull image data from cloud storage + run: dvc pull --remote upstream + # Produce the markdown diff report, which should look like: # ## Summary of changed images # @@ -32,32 +35,52 @@ jobs: # | Status | Path | # |----------|-------------------------------------| # | added | pygmt/tests/baseline/test_image.png | - - name: Put list of images that were added or changed into report + # | deleted | pygmt/tests/baseline/test_image2.png | + # | modified | pygmt/tests/baseline/test_image3.png | + - name: Generate the image diff report + env: + repo_token: ${{ secrets.GITHUB_TOKEN }} + id: image-diff run: | echo -e "## Summary of changed images\n" > report.md echo -e "This is an auto-generated report of images that have changed on the DVC remote\n" >> report.md dvc diff --show-md master HEAD >> report.md - cat report.md - - name: Pull image data from cloud storage - run: dvc pull --remote upstream - - - name: Put image diff(s) into report - env: - repo_token: ${{ secrets.GITHUB_TOKEN }} - id: image-diff - run: | - # Get just the filename of the changed image from the report - awk 'NF==5 && NR>=7 {print $4}' report.md > diff_files.txt + # Get just the filename of the added and modified image from the report + awk 'NF==5 && NR>=7 && $2=="added" {print $4}' report.md > added_files.txt + awk 'NF==5 && NR>=7 && $2=="modified" {print $4}' report.md > modified_files.txt # Append each image to the markdown report echo -e "## Image diff(s)\n" >> report.md echo -e "
\n" >> report.md + # Added images + echo -e "### Added images\n" >> report.md while IFS= read -r line; do echo -e "- $line \n" >> report.md cml-publish --title $line --md "$line" >> report.md < /dev/null - done < diff_files.txt + done < added_files.txt + + # Modified images + echo -e "### Modified images\n" >> report.md + # Upload new images + while IFS= read -r line; do + cml-publish --title $line --md "$line" > modified_images_new.md < /dev/null + done < modified_files.txt + + # Pull images in the master branch from cloud storage + git checkout master + dvc pull --remote upstream + # Upload old images + while IFS= read -r line; do + cml-publish --title $line --md "$line" > modified_images_old.md < /dev/null + done < modified_files.txt + + # Append image report for modified images + echo -e "| Path | Old | New |" >> report.md + echo -e "|---|---|---|" >> report.md + paste modified_files.txt modified_images_old.md modified_images_new.md -d"|" | + awk -F"|" 'function basename(file) {sub(".*/", "", file); return file} {printf("| %s | %s | %s |\n", basename($1), $2, $3)}' >> report.md echo -e "
\n" >> report.md From d581a6b27bcd7d37d8f9303538302e301183dc96 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 21 Apr 2021 13:53:51 -0400 Subject: [PATCH 3/3] Revert "Testing changes for added, changed, and deleted dvc files" This reverts commit cff85bfd7c47a145d2cab702f03f9df5bd19010f. --- pygmt/tests/baseline/test_basemap_add.png.dvc | 4 ---- pygmt/tests/baseline/test_basemap_compass.png.dvc | 4 ++-- pygmt/tests/baseline/test_basemap_map_scale.png.dvc | 4 ++++ pygmt/tests/test_basemap.py | 9 +++++---- 4 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 pygmt/tests/baseline/test_basemap_add.png.dvc create mode 100644 pygmt/tests/baseline/test_basemap_map_scale.png.dvc diff --git a/pygmt/tests/baseline/test_basemap_add.png.dvc b/pygmt/tests/baseline/test_basemap_add.png.dvc deleted file mode 100644 index 9400ed7cfff..00000000000 --- a/pygmt/tests/baseline/test_basemap_add.png.dvc +++ /dev/null @@ -1,4 +0,0 @@ -outs: -- md5: 40ed35b2a39ff16ad7e3e90946adc7c5 - size: 5773 - path: test_basemap_add.png diff --git a/pygmt/tests/baseline/test_basemap_compass.png.dvc b/pygmt/tests/baseline/test_basemap_compass.png.dvc index 7be2c24e2df..13c48fad715 100644 --- a/pygmt/tests/baseline/test_basemap_compass.png.dvc +++ b/pygmt/tests/baseline/test_basemap_compass.png.dvc @@ -1,4 +1,4 @@ outs: -- md5: 1b7ed2d28e7a9521de014d95c0f7c29b - size: 47646 +- md5: 5ecccc4123b28636b62e01f642006ae4 + size: 90778 path: test_basemap_compass.png diff --git a/pygmt/tests/baseline/test_basemap_map_scale.png.dvc b/pygmt/tests/baseline/test_basemap_map_scale.png.dvc new file mode 100644 index 00000000000..b952b792c59 --- /dev/null +++ b/pygmt/tests/baseline/test_basemap_map_scale.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: f1ff6ede343ce3d2fc42cbe9ef0ba96b + size: 40128 + path: test_basemap_map_scale.png diff --git a/pygmt/tests/test_basemap.py b/pygmt/tests/test_basemap.py index cbfb65846af..726661ab165 100644 --- a/pygmt/tests/test_basemap.py +++ b/pygmt/tests/test_basemap.py @@ -92,7 +92,7 @@ def test_basemap_compass(): """ fig = Figure() fig.basemap( - region=[120, 128.5, 26, 27], + region=[127.5, 128.5, 26, 27], projection="H15c", frame=True, compass="jMC+w5c+d11.5", @@ -101,14 +101,15 @@ def test_basemap_compass(): @pytest.mark.mpl_image_compare -def test_basemap_add(): +def test_basemap_map_scale(): """ - Create a map. + Create a map with a map scale. """ fig = Figure() fig.basemap( - region=[120, 128.5, 26, 27], + region=[127.5, 128.5, 26, 27], projection="H15c", frame=True, + map_scale="jMC+c26.5+w10k+f+l", ) return fig