write.config.PEPRMT() errors when the event file has no supported events for the site
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in write.config.PEPRMT() and trace how supported events are filtered and sorted; the issue names this function but no source file or test path. Reproduce with an event list containing only planting, then add a focused regression test and confirm the run produces the same run_data.csv as a run with no events.
Written by the indexing model from the issue text.
Description
Summary
write.config.PEPRMT() keeps only the supported event types (salinity, elevation) and then sorts the remaining events by date:
evt_order <- sapply(evts, \(x) x$date) |> as.Date() |> order()
If no supported event remains, evts is an empty list, sapply() returns list(), and as.Date(list()) stops with an error.
When this happens
- the site's
eventsarray is empty, or - every event is of a type PEPRMT does not use (for example only
planting). The events JSON is shared between models, so a file with only other models' events is a realistic input.
Reproduction (on develop)
Run write.config.PEPRMT() with run$inputs$event_json pointing at
[{"site_id": "S1", "events": [{"event_type": "planting", "date": "2020-01-02"}]}]
INFO Ignoring unsupported event types 'planting'. Supported event types are: 'salinity', 'elevation'
Error in as.Date.default(sapply(evts, function(x) x$date)) :
do not know how to convert 'sapply(evts, function(x) x$date)' to class "Date"
With no event input at all, or with a mix of supported and unsupported events, it works.
Proposed fix
Only sort when length(evts) > 0. The run then produces the same run_data.csv as a run with no events. I have a branch with a small test that fails on develop and passes with the fix; happy to send a PR if wanted
- Dominant language
- R
- Stars
- 246
- Forks
- 322
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 15
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PecanProject/pecan
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PecanProject/pecan#4254 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PecanProject/pecan#4253 · 2 comments ·
Maintainers usually reply within 1 day
-
Annual NetCDF merge writes values to the wrong ensemble members and timestepsPossibly taken @ANAMASGARD claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
PecanProject/pecan#4251 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
data.land: prepare_pools fails to calculate woody biomass from TotLivBiom when AbvGrndWood is present without coarse rootsPossibly taken @coder-Yash886 claimed this 4 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
PecanProject/pecan#4243 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PecanProject/pecan#4236 ·
Maintainers usually reply within 1 day
All issues in PecanProject/pecan
Similar issues
-
DataSet inherits from DotNetWrapper but has no .NET pointer, so NetObject methods failPossibly taken @PavelBal claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Open-Systems-Pharmacology/OSPSuite-R#2076 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
rfordatascience/tidytuesday#1105 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Huber-group-EMBL/remart#17 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 75/100
cran-task-views/Spatial#130 ·