Skip to content

Commit c736322

Browse files
authored
Update CI workflows (#28)
* Update CI workflows and grib_index_rewind fix Update actions to latest versions and check newest eccodes. Fix for grib_index_rewind being removed from public API.
1 parent 6508d2e commit c736322

14 files changed

+83
-78
lines changed

.github/workflows/check-latest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
env:
3131
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3232
R_KEEP_PKG_SOURCE: yes
33-
ECCODES_VERSION: 2.29.0
33+
ECCODES_VERSION: 2.36.0
3434

3535
steps:
36-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
3737

3838
- uses: r-lib/actions/setup-pandoc@v2
3939

.github/workflows/check-minimum.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
ECCODES_VERSION: 2.19.0
3434

3535
steps:
36-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
3737

3838
- uses: r-lib/actions/setup-pandoc@v2
3939

@@ -62,7 +62,7 @@ jobs:
6262
- name: Build eccodes from source (macOS)
6363
if: runner.os == 'macOS'
6464
env:
65-
OPENJPEG_INCLUDE_DIR: /usr/local/include/openjpeg-2.5
65+
OPENJPEG_INCLUDE_DIR: /opt/homebrew/include/openjpeg-2.5
6666
run: ./install_eccodes.sh
6767
shell: bash
6868

.github/workflows/check-standard.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
R_KEEP_PKG_SOURCE: yes
3434

3535
steps:
36-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
3737

3838
- uses: r-lib/actions/setup-pandoc@v2
3939

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
env:
2020
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323

2424
- uses: r-lib/actions/setup-r@v2
2525
with:

.github/workflows/test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2121

2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424

2525
- uses: r-lib/actions/setup-r@v2
2626
with:

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: gribr
22
Type: Package
33
Title: Read GRIB Files
4-
Version: 1.2.6
5-
Date: 2023-07-10
4+
Version: 1.2.7
5+
Date: 2024-07-12
66
Author: Nathan Wendt <[email protected]>
77
Maintainer: Nathan Wendt <[email protected]>
88
BugReports: https://github.com/nawendt/gribr/issues

cleanup.win

Lines changed: 0 additions & 3 deletions
This file was deleted.

configure

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.71 for gribr 1.2.6.
3+
# Generated by GNU Autoconf 2.71 for gribr 1.2.7.
44
#
55
# Report bugs to <[email protected]>.
66
#
@@ -610,8 +610,8 @@ MAKEFLAGS=
610610
# Identity of this package.
611611
PACKAGE_NAME='gribr'
612612
PACKAGE_TARNAME='gribr'
613-
PACKAGE_VERSION='1.2.6'
614-
PACKAGE_STRING='gribr 1.2.6'
613+
PACKAGE_VERSION='1.2.7'
614+
PACKAGE_STRING='gribr 1.2.7'
615615
PACKAGE_BUGREPORT='[email protected]'
616616
PACKAGE_URL=''
617617

@@ -1260,7 +1260,7 @@ if test "$ac_init_help" = "long"; then
12601260
# Omit some internal or obsolete options to make the list less imposing.
12611261
# This message is too long to be a string in the A/UX 3.1 sh.
12621262
cat <<_ACEOF
1263-
\`configure' configures gribr 1.2.6 to adapt to many kinds of systems.
1263+
\`configure' configures gribr 1.2.7 to adapt to many kinds of systems.
12641264
12651265
Usage: $0 [OPTION]... [VAR=VALUE]...
12661266
@@ -1322,7 +1322,7 @@ fi
13221322

13231323
if test -n "$ac_init_help"; then
13241324
case $ac_init_help in
1325-
short | recursive ) echo "Configuration of gribr 1.2.6:";;
1325+
short | recursive ) echo "Configuration of gribr 1.2.7:";;
13261326
esac
13271327
cat <<\_ACEOF
13281328
@@ -1406,7 +1406,7 @@ fi
14061406
test -n "$ac_init_help" && exit $ac_status
14071407
if $ac_init_version; then
14081408
cat <<\_ACEOF
1409-
gribr configure 1.2.6
1409+
gribr configure 1.2.7
14101410
generated by GNU Autoconf 2.71
14111411
14121412
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1624,7 +1624,7 @@ cat >config.log <<_ACEOF
16241624
This file contains any messages produced by compilers while
16251625
running configure, to aid debugging if configure makes a mistake.
16261626
1627-
It was created by gribr $as_me 1.2.6, which was
1627+
It was created by gribr $as_me 1.2.7, which was
16281628
generated by GNU Autoconf 2.71. Invocation command line was
16291629
16301630
$ $0$ac_configure_args_raw
@@ -4235,7 +4235,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
42354235
# report actual input values of CONFIG_FILES etc. instead of their
42364236
# values after options handling.
42374237
ac_log="
4238-
This file was extended by gribr $as_me 1.2.6, which was
4238+
This file was extended by gribr $as_me 1.2.7, which was
42394239
generated by GNU Autoconf 2.71. Invocation command line was
42404240
42414241
CONFIG_FILES = $CONFIG_FILES
@@ -4290,7 +4290,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
42904290
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
42914291
ac_cs_config='$ac_cs_config_escaped'
42924292
ac_cs_version="\\
4293-
gribr config.status 1.2.6
4293+
gribr config.status 1.2.7
42944294
configured by $0, generated by GNU Autoconf 2.71,
42954295
with options \\"\$ac_cs_config\\"
42964296

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([gribr],[1.2.6],[[email protected]])
1+
AC_INIT([gribr],[1.2.7],[[email protected]])
22

33
AC_CONFIG_MACRO_DIR([tools/m4])
44

configure.win

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/grib_api_extra.h

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/grib_select.c

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <string.h>
55

66
#include "gribr.h"
7-
#include "grib_api_extra.h"
87

98
SEXP gribr_select(SEXP gribr_filePath, SEXP gribr_fileHandle, SEXP gribr_keyList, SEXP gribr_isMulti) {
109
int err;
@@ -87,16 +86,10 @@ SEXP gribr_select(SEXP gribr_filePath, SEXP gribr_fileHandle, SEXP gribr_keyList
8786
codes_grib_multi_support_on(DEFAULT_CONTEXT);
8887
}
8988

90-
index = codes_index_new(DEFAULT_CONTEXT, keyString, &err);
89+
index = codes_index_new_from_file(DEFAULT_CONTEXT, filePath, keyString, &err);
9190
if (err) {
9291
gerror("unable to create index", err);
9392
}
94-
nfree(keyString);
95-
96-
err = codes_index_add_file(index, filePath);
97-
if (err) {
98-
gerror("unable to add file to index", err);
99-
}
10093

10194
/* Have to grab handle from file first in order to get
10295
* native key types. Will not work with handle from
@@ -112,37 +105,42 @@ SEXP gribr_select(SEXP gribr_filePath, SEXP gribr_fileHandle, SEXP gribr_keyList
112105
if (i % INTERRUPT_FREQ == 0) {
113106
R_CheckUserInterrupt();
114107
}
108+
115109
lenKeys = xlength(VECTOR_ELT(gribr_keyList, i));
110+
116111
for (j = 0; j < lenKeys; j++) {
117112
keyName = CHAR(STRING_ELT(getAttrib(VECTOR_ELT(gribr_keyList, i), R_NamesSymbol), j));
118113
err = codes_get_native_type(h, keyName, &keyType);
114+
119115
if (err) {
120116
gerror("unable to get native type", err);
121117
}
118+
122119
switch (keyType) {
123-
case CODES_TYPE_DOUBLE:
124-
kd = asReal(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j));
125-
codes_index_select_double(index, keyName, kd);
126-
break;
127-
case CODES_TYPE_LONG:
128-
/* Need to coerce vector to integer as R list components entered
129-
* as integers really end up being numeric (double in C). Doing
130-
* corecion here makes the most sense as the type gets deciced in
131-
* the get_naitve_type call. The C routines know more about the
132-
* typing than the R routines.
133-
*/
134-
ki = (long)asReal(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j));
135-
codes_index_select_long(index, keyName, ki);
136-
break;
137-
case CODES_TYPE_STRING:
138-
ks = CHAR(asChar(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j)));
139-
codes_index_select_string(index, keyName, ks);
140-
break;
141-
default:
142-
/* Skip other key types with no codes_select_* methods to handle them */
143-
break;
144-
}
120+
case CODES_TYPE_DOUBLE:
121+
kd = asReal(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j));
122+
codes_index_select_double(index, keyName, kd);
123+
break;
124+
case CODES_TYPE_LONG:
125+
/* Need to coerce vector to integer as R list components entered
126+
* as integers really end up being numeric (double in C). Doing
127+
* corecion here makes the most sense as the type gets deciced in
128+
* the get_naitve_type call. The C routines know more about the
129+
* typing than the R routines.
130+
*/
131+
ki = (long)asReal(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j));
132+
codes_index_select_long(index, keyName, ki);
133+
break;
134+
case CODES_TYPE_STRING:
135+
ks = CHAR(asChar(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j)));
136+
codes_index_select_string(index, keyName, ks);
137+
break;
138+
default:
139+
/* Skip other key types with no codes_select_* methods to handle them */
140+
break;
141+
}
145142
}
143+
146144
index_count = 0;
147145
while((hi = codes_handle_new_from_index(index, &err))) {
148146
if (err) {
@@ -156,10 +154,41 @@ SEXP gribr_select(SEXP gribr_filePath, SEXP gribr_fileHandle, SEXP gribr_keyList
156154
error("gribr: no messages matched");
157155
}
158156

159-
grib_index_rewind(index);
160-
161157
REPROTECT(gribr_temp = allocVector(VECSXP, index_count), pro_temp);
162158

159+
/* Recreate index and redo selections. This is done as the index will have been
160+
* consumed to figure out the size of the vector needed. grib_index_rewind is no
161+
* longer available to do this efficiently. This will suffice until a better
162+
* approach is developed or exposed in the public API.
163+
*/
164+
index = codes_index_new_from_file(DEFAULT_CONTEXT, filePath, keyString, &err);
165+
166+
for (j = 0; j < lenKeys; j++) {
167+
keyName = CHAR(STRING_ELT(getAttrib(VECTOR_ELT(gribr_keyList, i), R_NamesSymbol), j));
168+
err = codes_get_native_type(h, keyName, &keyType);
169+
170+
if (err) {
171+
gerror("unable to get native type", err);
172+
}
173+
174+
switch (keyType) {
175+
case CODES_TYPE_DOUBLE:
176+
kd = asReal(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j));
177+
codes_index_select_double(index, keyName, kd);
178+
break;
179+
case CODES_TYPE_LONG:
180+
ki = (long)asReal(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j));
181+
codes_index_select_long(index, keyName, ki);
182+
break;
183+
case CODES_TYPE_STRING:
184+
ks = CHAR(asChar(VECTOR_ELT(VECTOR_ELT(gribr_keyList, i), j)));
185+
codes_index_select_string(index, keyName, ks);
186+
break;
187+
default:
188+
break;
189+
}
190+
}
191+
163192
m = 0;
164193
while((hi = codes_handle_new_from_index(index, &err)) && m < index_count) {
165194
if (err) {
@@ -174,6 +203,7 @@ SEXP gribr_select(SEXP gribr_filePath, SEXP gribr_fileHandle, SEXP gribr_keyList
174203

175204
codes_handle_delete(h);
176205
codes_index_delete(index);
206+
nfree(keyString);
177207

178208
grewind(file);
179209

src/gribr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SEXP gribr_grib_open(SEXP gribr_fileName);
1414
SEXP gribr_grib_list(SEXP gribr_fileHandle, SEXP gribr_filter,
1515
SEXP gribr_namespace, SEXP gribr_isMulti);
1616
SEXP gribr_grib_df(SEXP gribr_fileHandle, SEXP gribr_filter,
17-
SEXP gribr_namespace, SEXP gribr_isMulti);
17+
SEXP gribr_namespace, SEXP gribr_isMulti);
1818

1919
SEXP gribr_grib_length(SEXP gribr_fileHandle);
2020
SEXP gribr_is_null_ptr (SEXP gribr_ptr);

tests/testthat/test-messages.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
context("GRIB message retrieval and attributes")
22

3-
test_that("Incorrect message requests are handled correctly", {
3+
test_that("Message requests are handled correctly", {
44
g <- grib_open(system.file("extdata", "lfpw.grib1", package = "gribr"))
55

66
# grib_get_message

0 commit comments

Comments
 (0)