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

Add vue skeleton to host map #26

Merged
merged 18 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions 3_visualize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ targets:
3_visualize:
depends:
- 3_visualize/out/anomaly_peaks.svg
- src/assets/anomaly_peaks.svg

3_visualize/out/anomaly_peaks.svg:
command: build_peaks_svg(
Expand All @@ -25,6 +26,11 @@ targets:
svg_width = svg_width,
svg_height = svg_height)

src/assets/anomaly_peaks.svg:
command: send_to_vue(
target_name,
in_file = '3_visualize/out/anomaly_peaks.svg')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary but one final thing is that you don't need a separate function here. You can simply make file.copy() the function for the target.

src/assets/anomaly_peaks.svg:
    command: file.copy(
        to = target_name,
        from = '3_visualize/out/anomaly_peaks.svg')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol totally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just need to use to = and from = because target_name has to be passed in as the first arg

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need overwrite = TRUE in the file.copy function so this works as expected, otherwise it silently doesn't replace the to target even when the from file has changed. Remember this issue @lindsayplatt ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I still haven't learned my lesson! Thanks @jread-usgs. They had that in the custom function below but I neglected to carry it over to this suggestion :)


3_visualize/out/svg_list.csv:
command: list_svg_files(
target_name,
Expand Down
11 changes: 5 additions & 6 deletions 3_visualize/src/build_peaks_svg.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ build_peaks_svg <- function(out_file, data_in, sites_sf, svg_width, svg_height)
}

xml2::write_xml(svg_root, file = out_file)

# Copy to vue
file.copy(out_file,
sprintf("src/assets/anomaly_peaks_%s_%s.svg",
gsub("-", "", min(data_in$Date)),
gsub("-", "", max(data_in$Date))),
}
send_to_vue <- function(out_file, in_file){
# Copy current time period to vue
file.copy(in_file,
out_file,
overwrite = TRUE)

}
Expand Down