Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions .github/workflows/dvc-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
- name: Setup continuous machine learning (CML)
uses: iterative/[email protected]

- name: Pull image data from cloud storage
run: dvc pull --remote upstream

# workaround from https://github.com/iterative/cml/issues/1377
- name: Setup NodeJS
uses: actions/setup-node@v1
Expand Down Expand Up @@ -65,43 +62,40 @@ jobs:
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

# Pull image data from cloud storage
dvc pull --remote upstream
dvc diff --show-md main HEAD >> report.md

# 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

# Backup new images in the baseline-new directory
mkdir pygmt/tests/baseline-new
cp pygmt/tests/baseline/*.png pygmt/tests/baseline-new/
# Pull images in the main branch from cloud storage
git checkout main
dvc pull --remote upstream

# Append each image to the markdown report
echo -e "## Image diff(s)\n" >> report.md
echo -e "<details>\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
echo -e "- $(basename $line) \n" >> report.md
echo -e "![](${line/baseline/baseline-new})" >> report.md
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 main branch from cloud storage
git checkout main
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
while IFS= read -r line; do
echo -e "| $(basename $line) | ![]($line) | ![](${line/baseline/baseline-new}) |" >> report.md
done < modified_files.txt

echo -e "</details>\n" >> report.md

Expand Down
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_basemap.png.dvc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
outs:
- md5: 3cf01816fa5dd3fbc1adc602557bb032
size: 6187
- md5: 35388aa0ddd861e337b8f47ba4f587dc
size: 7472
path: test_basemap.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_added.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: a5aaf4c3cbea32a3373721237e767789
size: 9420
path: test_basemap_added.png
4 changes: 0 additions & 4 deletions pygmt/tests/baseline/test_basemap_loglog.png.dvc

This file was deleted.

12 changes: 4 additions & 8 deletions pygmt/tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ def test_basemap():
Create a simple basemap plot.
"""
fig = Figure()
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c", frame="afg")
fig.basemap(region=[10, 70, -3, 8], projection="X10c/6c", frame="afg")
return fig


@pytest.mark.mpl_image_compare
def test_basemap_loglog():
def test_basemap_added():
"""
Create a loglog basemap plot.
Create a simple basemap plot.
"""
fig = Figure()
fig.basemap(
region=[1, 10000, 1e20, 1e25],
projection="X16cl/12cl",
frame=["WS", "x2+lWavelength", "ya1pf3+lPower"],
)
fig.basemap(region=[10, 70, -20, 20], projection="X10c/6c", frame="afg")
return fig


Expand Down