Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Jan 30, 2025
2 parents f9a25f1 + 1547d4b commit dc21726
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,6 @@ jobs:
run: |
cd build
PATH=~/tmp/bin:$PATH ctest . --rerun-failed --output-on-failure -VV
df -h
pwd
if: ${{ failure() }}
13 changes: 11 additions & 2 deletions .github/workflows/run_tests_win_cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
plugin_dir_option: ["", "--without-plugin-dir"]

steps:
- name: Set safe directory for Git
shell: pwsh
run: git config --global --add safe.directory /cygdrive/d/a/netcdf-c/netcdf-c

- name: Fix line endings
shell: pwsh
run: git config --global core.autocrlf input
Expand Down Expand Up @@ -101,10 +105,15 @@ jobs:
runs-on: windows-latest
defaults:
run:
shell: bash -eo pipefail -o igncr "{0}"
shell: C:/cygwin/bin/bash.exe -eo pipefail -o igncr "{0}"

steps:
# shell: C:/cygwin/bin/bash.exe -eo pipefail -o igncr "{0}"

steps:
- name: Set safe directory for Git
shell: pwsh
run: git config --global --add safe.directory /cygdrive/d/a/netcdf-c/netcdf-c

- run: git config --global core.autocrlf input
shell: pwsh
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions include/ncs3sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
typedef enum NCS3SVC {NCS3UNK=0, /* unknown */
NCS3=1, /* s3.amazon.aws */
NCS3GS=2, /* storage.googleapis.com */
#ifdef NETCDF_ENABLE_ZOH
NCS3ZOH=4, /* ZoH Server */
#endif
} NCS3SVC;

/* Opaque Handles */
Expand Down
2 changes: 2 additions & 0 deletions libdispatch/ds3util.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ NC_iss3(NCURI* uri, NCS3SVC* svcp)
/* is the protocol "s3" or "gs3" or "zoh" ? */
if(strcasecmp(uri->protocol,"s3")==0) {iss3 = 1; svc = NCS3; goto done;}
if(strcasecmp(uri->protocol,"gs3")==0) {iss3 = 1; svc = NCS3GS; goto done;}
#ifdef NETCDF_ENABLE_ZOH
if(strcasecmp(uri->protocol,"zoh")==0) {iss3 = 1; svc = NCS3ZOH; goto done;}
#endif
/* Is "s3" or "gs3" in the mode list? */
if(NC_testmode(uri,"s3")) {iss3 = 1; svc = NCS3; goto done;}
if(NC_testmode(uri,"gs3")) {iss3 = 1; svc = NCS3GS; goto done;}
Expand Down
3 changes: 2 additions & 1 deletion libnczarr/zarr.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,13 @@ applycontrols(NCZ_FILE_INFO_T* zinfo)
NClist* modelist = nclistnew();
size64_t noflags = 0; /* track non-default negative flags */

#ifdef NETCDF_ENABLE_ZOH
/* Track http: vs https: */
if(strncmp("http://",zinfo->common.file->hdr.name,7) == 0 ||
strncmp("https://",zinfo->common.file->hdr.name,8) == 0 ){
zinfo->mapimpl = NCZM_ZOH;
}

#endif
/* Apply controls from URL mode=... */
if((value = controllookup(zinfo->urlcontrols,"mode")) != NULL) {
if((stat = NCZ_comma_parse(value,modelist))) goto done;
Expand Down
4 changes: 4 additions & 0 deletions libnczarr/zinfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,10 @@ NCZ_infer_storage_type(NC_FILE_INFO_T* file, NCURI* url, NCZM_IMPL* implp)
#ifdef NETCDF_ENABLE_S3
else if(NC_testmode(url, "s3")) impl = NCZM_S3;
else if(NC_testmode(url, "gs3")) impl = NCZM_GS3;
#ifdef NETCDF_ENABLE_ZOH
else if(NC_testmode(url, "zoh")) impl = NCZM_ZOH;
#endif
#endif
#ifdef NETCDF_ENABLE_NCZARR_ZIP
else if(NC_testmode(url, "zip")) impl = NCZM_ZIP;
#endif
Expand Down Expand Up @@ -439,11 +441,13 @@ NCZ_get_map(NC_FILE_INFO_T* file, NCURI* url, mode_t mode, size64_t constraints,
else
{if((stat = nczmap_open(impl,path,mode,constraints,params,&map))) goto done;}
break;
#ifdef NETCDF_ENABLE_ZOH
case NCZM_ZOH:
if(create) {stat = NC_ENOTZARR; goto done;}
constraints |= FLAG_ZOH;
if((stat = nczmap_open(impl,path,mode,constraints,params,&map))) goto done;
break;
#endif
case NCZM_UNDEF:
stat = NC_EURL;
goto done;
Expand Down
2 changes: 2 additions & 0 deletions libnczarr/zinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ typedef struct NCZ_FILE_INFO {
# define FLAG_XARRAYDIMS 8 /* Utilize the xarray _ARRAY_DIMENSIONS attribute */
# define FLAG_NCZARR_KEY 16 /* _nczarr_xxx keys are stored in object and not in _nczarr_attrs */
# define FLAG_NOCONSOLIDATED 32 /* Suppress consolidated metadata */
#ifdef NETCDF_ENABLE_ZOH
# define FLAG_ZOH 32 /* Usind ZoH Protocol */
#endif
NCZM_IMPL mapimpl;
struct NCZ_Formatter* dispatcher;
struct NCZ_META_HDR* metastate; /* Hold per-format state */
Expand Down
13 changes: 12 additions & 1 deletion libnczarr/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ nczmap_features(NCZM_IMPL impl)
#endif

#ifdef NETCDF_ENABLE_S3
case NCZM_S3: case NCZM_GS3 case NCZM_ZOH:
case NCZM_S3: case NCZM_GS3:
#endif
#ifdef NETCDF_ENABLE_ZOH
case NCZM_ZOH:
return zmap_s3sdk.features;
#endif
default: break;
Expand Down Expand Up @@ -63,7 +66,9 @@ nczmap_create(NCZM_IMPL impl, const char *path, mode_t mode, size64_t flags, voi
#ifdef NETCDF_ENABLE_S3
case NCZM_S3:
case NCZM_GS3:
#ifdef NETCDF_ENABLE_ZOH
case NCZM_ZOH:
#endif
stat = zmap_s3sdk.create(path, mode, flags, parameters, &map);
if(stat) goto done;
break;
Expand Down Expand Up @@ -106,10 +111,12 @@ nczmap_open(NCZM_IMPL impl, const char *path, mode_t mode, size64_t flags, void*
stat = zmap_s3sdk.open(path, mode, flags, parameters, &map);
if(stat) goto done;
break;
#ifdef NETCDF_ENABLE_ZOH
case NCZM_ZOH:
stat = zmap_zoh.open(path, mode, flags, parameters, &map);
if(stat) goto done;
break;
#endif
#endif
default:
{stat = REPORT(NC_ENOTBUILT,"nczmap_open"); goto done;}
Expand Down Expand Up @@ -141,8 +148,10 @@ nczmap_truncate(NCZM_IMPL impl, const char *path)
case NCZM_GS3:
if((stat = zmap_s3sdk.truncate(path))) goto done;
break;
#ifdef NETCDF_ENABLE_ZOH
case NCZM_ZOH:
{stat = REPORT(NC_EZAR,"nczmap_truncate not supported for Zarr-Over-HTTP"); goto done;}
#endif
#endif
default:
{stat = REPORT(NC_ENOTBUILT,"nczmap_truncate"); goto done;}
Expand Down Expand Up @@ -569,7 +578,9 @@ NCZ_mapkind(NCZM_IMPL impl)
case NCZM_ZIP: return "NCZM_ZIP";
case NCZM_S3: return "NCZM_S3";
case NCZM_GS3: return "NCZM_GS3";
#ifdef NETCDF_ENABLE_ZOH
case NCZM_ZOH: return "NCZM_ZOH";
#endif
default: break;
}
return "Unknown";
Expand Down
4 changes: 4 additions & 0 deletions libnczarr/zmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ NCZM_FILE=1, /* File system directory-based implementation */
NCZM_ZIP=2, /* Zip-file based implementation */
NCZM_S3=3, /* Amazon S3 implementation */
NCZM_GS3=4, /* Google S3 implementation */
#ifdef NETCDF_ENABLE_ZOH
NCZM_ZOH=5, /* Zarr-Over-HTTP server; piggybacks on S3 implementation */
#endif
} NCZM_IMPL;

/* Define the default map implementation */
Expand Down Expand Up @@ -237,8 +239,10 @@ extern NCZMAP_DS_API zmap_zip;
#endif
#ifdef NETCDF_ENABLE_S3
extern NCZMAP_DS_API zmap_s3sdk;
#ifdef NETCDF_ENABLE_ZOH
extern NCZMAP_DS_API zmap_zoh;
#endif
#endif

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions libnczarr/zmap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,10 @@ zfilelistall(NCZMAP* map, const char* prefixkey, NClist* matches)

/* prime the key tracker */
/* Ensure leading '/' */
#ifndef _MSC_VER
if(fullpath[0] != '/')
ncbytescat(path,"/");
#endif
ncbytescat(path,fullpath);
ncbytescat(path,prefixkey);
/* Ensure no trailing '/' */
Expand Down
15 changes: 14 additions & 1 deletion libnczarr/zmap_s3sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ zs3create(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMA

if(!zs3initialized) zs3initialize();

#ifdef NETCDF_ENABLE_ZOH
if(flags & FLAG_ZOH) {stat = NC_EZARR; goto done;}
#endif

/* Parse the URL */
ncuriparse(path,&url);
Expand Down Expand Up @@ -216,7 +218,11 @@ zs3open(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMAP*
if((z3map = (ZS3MAP*)calloc(1,sizeof(ZS3MAP))) == NULL)
{stat = NC_ENOMEM; goto done;}

#ifdef NETCDF_ENABLE_ZOH
z3map->map.format = ((flags & FLAG_ZOH)?NCZM_ZOH:NCZM_S3);
#else
z3map->map.format = NCZM_S3;
#endif
z3map->map.url = strdup(path);
z3map->map.mode = mode;
z3map->map.flags = flags;
Expand All @@ -230,7 +236,10 @@ zs3open(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMAP*

z3map->s3client = NC_s3sdkcreateclient(&z3map->s3);

if(!flags & FLAG_ZOH) {
#ifdef NETCDF_ENABLE_ZOH
if(!flags & FLAG_ZOH)
#endif
{
content = nclistnew();
if((stat = NC_s3sdklist(z3map->s3client,z3map->s3.bucket,z3map->s3.rootkey,&nkeys,NULL,&z3map->errmsg)))
goto done;
Expand Down Expand Up @@ -668,6 +677,7 @@ freevector(size_t nkeys, char** list)
/**************************************************/
/* no-op functions for ZOH
#ifdef NETCDF_ENABLE_ZOH
static int
zs3create(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMAP** mapp)
Expand All @@ -693,6 +703,7 @@ zohlistall(NCZMAP* map, const char* prefix, NClist* matches)
return NC_EZARR;
}
#endif
/**************************************************/

/* External API objects */
Expand All @@ -719,6 +730,7 @@ nczs3sdkapi = {
zs3listall
};

#ifdef NETCDF_ENABLE_ZOH
/* Dispatcher for ZOH */
NCZMAP_DS_API zmap_zoh;
NCZMAP_DS_API zmap_zoh = {
Expand All @@ -740,3 +752,4 @@ nczzohapi = {
zohlist,
zohlistall,
};
#endif
2 changes: 1 addition & 1 deletion nczarr_test/run_chunkcases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ THISDIR=`pwd`
cd $ISOPATH

TC="${execdir}/test_chunkcases -4"
ZM="${execdir}/zmapio -t int"
ZMD="${ZMD} -t int"

remfile() {
case "$zext" in
Expand Down
14 changes: 11 additions & 3 deletions nczarr_test/zmapio.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static struct Type {
struct Dumpptions {
int debug;
int meta_only;
int noobjectsize;
Mapop mop;
char infile[4096];
NCZM_IMPL impl;
Expand Down Expand Up @@ -114,7 +115,7 @@ static void nccheck(int stat, int line)
static void
zmapusage(void)
{
fprintf(stderr,"usage: zmapio [-2|-3][-t <type>][-d][-v][-h][-x] <file>\n");
fprintf(stderr,"usage: zmapio [-2|-3][-t <type>][-d][-v][-h][-x][-F<format>][-N][-T<tracelevel>][-Xm] <file>\n");
exit(1);
}

Expand Down Expand Up @@ -156,7 +157,7 @@ main(int argc, char** argv)
/* Init options */
memset((void*)&dumpoptions,0,sizeof(dumpoptions));

while ((c = getopt(argc, argv, "23dhvx:t:F:T:X:")) != EOF) {
while ((c = getopt(argc, argv, "23dhvx:t:F:NT:X:")) != EOF) {
switch(c) {
case '2':
dumpoptions.zarrformat = 2;
Expand Down Expand Up @@ -184,6 +185,9 @@ main(int argc, char** argv)
case 'F':
strcpy(dumpoptions.format,optarg);
break;
case 'N':
dumpoptions.noobjectsize = 1; /* suppress the objectsize */
break;
case 'T':
nctracelevel(atoi(optarg));
break;
Expand Down Expand Up @@ -365,7 +369,11 @@ objdump(void)
assert(content != NULL);
if(kind == OK_CHUNK)
len = ceildiv(len,dumpoptions.nctype->typesize);
printf("[%zu] %s : (%llu)",depth,obj,len);
printf("[%zu] %s : ",depth,obj);
if(dumpoptions.noobjectsize)
printf("()");
else
printf("(%llu)",len);
if(kind == OK_CHUNK && dumpoptions.nctype->nctype != NC_STRING)
printf(" (%s)",dumpoptions.nctype->typename);
printf(" |");
Expand Down

0 comments on commit dc21726

Please sign in to comment.