From b151e586c4ccb0fddb61c348b493c4016acc0729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sat, 23 May 2020 08:51:39 -0400 Subject: [PATCH 1/7] DataFramesMeta --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index bbdd196..19a023e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,3 +1,4 @@ [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +"DataFramesMeta" = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" From d61d318b6152ec9777af53ba424b25924e68c76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sat, 23 May 2020 08:53:44 -0400 Subject: [PATCH 2/7] deploy only from master --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 605f39b..d51354b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,6 +55,7 @@ jobs: publish_webpage: needs: [get_data, draw_the_figure] runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' steps: - name: Checkout uses: actions/checkout@v2 From 399584465948d7fb50438cf3bbabdfec8097a69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sat, 23 May 2020 08:56:25 -0400 Subject: [PATCH 3/7] Upload to a single artifact to simplify the workflpow --- .github/workflows/main.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d51354b..cfc907b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,9 +24,9 @@ jobs: - name: Download occurrence data run: julia --project scripts/get_occurrences.jl - name: Upload occurrence data - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: - name: occurrence_data + name: project_data path: occurrences.csv draw_the_figure: needs: [get_data] @@ -44,13 +44,13 @@ jobs: - name: Donwload occurrence data uses: actions/download-artifact@v2 with: - name: occurrence_data + name: project_data - name: Make the figure run: python scripts/make_plot.py - name: Upload map - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: - name: map + name: project_data path: map.png publish_webpage: needs: [get_data, draw_the_figure] @@ -59,15 +59,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Download occurrence data - uses: actions/download-artifact@v2 - with: - name: occurrence_data - path: dist - - name: Download map + - name: Download data uses: actions/download-artifact@v2 with: - name: map + name: project_data path: dist - name: Deploy the webpage from the dist folder uses: peaceiris/actions-gh-pages@v3 From 7aa40b8cbbefdb98f6a2d385ba7bdcc1cdad34c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sat, 23 May 2020 09:12:04 -0400 Subject: [PATCH 4/7] use DataFramesMeta for the data prep --- scripts/get_occurrences.jl | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/scripts/get_occurrences.jl b/scripts/get_occurrences.jl index 87a846b..80a537e 100644 --- a/scripts/get_occurrences.jl +++ b/scripts/get_occurrences.jl @@ -1,5 +1,6 @@ import GBIF using DataFrames +using DataFramesMeta import CSV @@ -16,21 +17,11 @@ GBIF.occurrences!(occ) GBIF.occurrences!(occ) GBIF.occurrences!(occ) -raw_data = DataFrame(occ) +data = @linq DataFrame(occ) |> + where(:rank == "SPECIES"] |> + where(:name in "Amphiprion ".*["melanopus", "ocellaris", "clarkii"]) |> + where(:longitude > 0.0) |> + select([:name, :longitude, :latitude]) -# JUDGE NOT LEST YE BE JUDGED -raw_data = raw_data[raw_data.rank .== "SPECIES", :] -# Seriously -ok_names = "Amphiprion ".*["melanopus", "ocellaris", "clarkii"] -# It's 10pm -ok_index = map(f -> in(f, ok_names), raw_data.name) -# I'm so tired -raw_data = raw_data[ok_index, :] -# Can 2020 be over yet, please? -raw_data = raw_data[raw_data.longitude.>=0.0, :] -# I really should have used Query.jl or DataFramesMeta.jl is what I'm trying to say - -# Save only the columns we care about -data = select(raw_data, [:name, :longitude, :latitude]) CSV.write("occurrences.csv", data; writeheader=true) From 2d61d1b380fee5e2e55def8ccc6c49c7fe7bef7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sat, 23 May 2020 09:16:04 -0400 Subject: [PATCH 5/7] Update get_occurrences.jl --- scripts/get_occurrences.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/get_occurrences.jl b/scripts/get_occurrences.jl index 80a537e..66b3351 100644 --- a/scripts/get_occurrences.jl +++ b/scripts/get_occurrences.jl @@ -18,7 +18,7 @@ GBIF.occurrences!(occ) GBIF.occurrences!(occ) data = @linq DataFrame(occ) |> - where(:rank == "SPECIES"] |> + where(:rank == "SPECIES") |> where(:name in "Amphiprion ".*["melanopus", "ocellaris", "clarkii"]) |> where(:longitude > 0.0) |> select([:name, :longitude, :latitude]) From bf7561229107c9b30ec62e957bc742e328745776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sat, 23 May 2020 09:22:12 -0400 Subject: [PATCH 6/7] Update get_occurrences.jl --- scripts/get_occurrences.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/get_occurrences.jl b/scripts/get_occurrences.jl index 66b3351..d192cd5 100644 --- a/scripts/get_occurrences.jl +++ b/scripts/get_occurrences.jl @@ -18,9 +18,9 @@ GBIF.occurrences!(occ) GBIF.occurrences!(occ) data = @linq DataFrame(occ) |> - where(:rank == "SPECIES") |> - where(:name in "Amphiprion ".*["melanopus", "ocellaris", "clarkii"]) |> - where(:longitude > 0.0) |> + where(:rank .== "SPECIES") |> + where(:name .∈ ["Amphiprion ".*["melanopus", "ocellaris", "clarkii"]]) |> + where(:longitude .> 0.0) |> select([:name, :longitude, :latitude]) CSV.write("occurrences.csv", data; writeheader=true) From a66f745c154a3203d62dc0abc7b6630801aa4441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Sun, 24 May 2020 10:45:39 -0400 Subject: [PATCH 7/7] Update get_occurrences.jl --- scripts/get_occurrences.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/get_occurrences.jl b/scripts/get_occurrences.jl index d192cd5..96eb0c0 100644 --- a/scripts/get_occurrences.jl +++ b/scripts/get_occurrences.jl @@ -19,9 +19,10 @@ GBIF.occurrences!(occ) data = @linq DataFrame(occ) |> where(:rank .== "SPECIES") |> + select([:name, :longitude, :latitude]) |> where(:name .∈ ["Amphiprion ".*["melanopus", "ocellaris", "clarkii"]]) |> - where(:longitude .> 0.0) |> - select([:name, :longitude, :latitude]) + where(:longitude .> 0.0) + CSV.write("occurrences.csv", data; writeheader=true)