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

Provide byte-range reading of remote datasets #1267

Merged
merged 24 commits into from
Mar 19, 2019
Merged

Provide byte-range reading of remote datasets #1267

merged 24 commits into from
Mar 19, 2019

Conversation

DennisHeimbigner
Copy link
Collaborator

@DennisHeimbigner DennisHeimbigner commented Jan 2, 2019

Assume that you have the URL to a remote dataset
which is a normal netcdf-3 or netcdf-4 file.

This PR allows the netcdf-c to read that dataset's
contents as a netcdf file using HTTP byte ranges
if the remote server supports byte-range access.

Originally, this PR was set up to access Amazon S3 objects,
but it can also access other remote datasets such as those
provided by a Thredds server via the HTTPServer access protocol.
It may also work for other kinds of servers.

Note that this is not intended as a true production
capability because, as is known, this kind of access to
can be quite slow. In addition, the byte-range IO drivers
do not currently do any sort of optimization or caching.

An additional goal here is to gain some experience with
the Amazon S3 REST protocol.

This architecture and its use documented in
the file docs/byterange.dox.

There are currently two test cases:

  1. nc_test/tst_s3raw.c - this does a simple open, check format, close cycle
    for a remote netcdf-3 file and a remote netcdf-4 file.
  2. nc_test/test_s3raw.sh - this uses ncdump to investigate some remote
    datasets.

This PR also incorporates significantly changed model inference code
(see the superceded PR #1259).

  1. It centralizes the code that infers the dispatcher.
  2. It adds support for byte-range URLs

Other changes:

  1. NC_HDF5_finalize was not being properly called by nc_finalize().
  2. Fix minor bug in ncgen3.l
  3. fix memory leak in nc4info.c
  4. add code to walk the .daprc triples and to replace protocol=
    fragment tag with a more general mode= tag.

Final Note:
Th inference code is still way too complicated. We need to move
to the validfile() model used by netcdf Java, where each
dispatcher is asked if it can process the file. This decentralizes
the inference code. This will be done after all the major new
dispatchers (PIO, Zarr, etc) have been implemented.

re: issue #1251

Assume that you have the URL to a remote dataset
which is a normal netcdf-3 or netcdf-4 file.

This PR allows the netcdf-c to read that dataset's
contents as a netcdf file using HTTP byte ranges
if the remote server supports byte-range access.

Originally, this PR was set up to access Amazon S3 objects,
but it can also access other remote datasets such as those
provided by a Thredds server via the HTTPServer access protocol.
It may also work for other kinds of servers.

Note that this is not intended as a true production
capability because, as is known, this kind of access to
can be quite slow. In addition, the byte-range IO drivers
do not currently do any sort of optimization or caching.

An additional goal here is to gain some experience with
the Amazon S3 REST protocol.

This architecture and its use documented in
the file docs/byterange.dox.

There are currently two test cases:

1. nc_test/tst_s3raw.c - this does a simple open, check format, close cycle
   for a remote netcdf-3 file and a remote netcdf-4 file.
2. nc_test/test_s3raw.sh - this uses ncdump to investigate some remote
   datasets.

This PR also incorporates significantly changed model inference code
(see the superceded PR #1259).

1. It centralizes the code that infers the dispatcher.
2. It adds support for byte-range URLs

Other changes:

1. NC_HDF5_finalize was not being properly called by nc_finalize().
2. Fix minor bug in ncgen3.l
3. fix memory leak in nc4info.c
4. add code to walk the .daprc triples and to replace protocol=
   fragment tag with a more general mode= tag.

Final Note:
Th inference code is still way too complicated. We need to move
to the validfile() model used by netcdf Java, where each
dispatcher is asked if it can process the file. This decentralizes
the inference code. This will be done after all the major new
dispatchers (PIO, Zarr, etc) have been implemented.
@WardF
Copy link
Member

WardF commented Jan 2, 2019

This pull request introduces 2 alerts when merging bf2746b into b16ecea - view on LGTM.com

new alerts:

  • 2 for Empty branch of conditional

Comment posted by LGTM.com

@DennisHeimbigner
Copy link
Collaborator Author

Ok, I fixed the alerts, but I am baffled by the appveyor complaint.
It looks like we have amismatch between a struct and the initializers for it.
But I cannot see the mismatch. Even a count of the fields seems to be ok.

@DennisHeimbigner
Copy link
Collaborator Author

Ok, so I compared the problem structure (in H5FDpublic.h) for versions 1.8.17
and 1.10.3, and they differ. So I need to do some conditionals depending on the
HDF5 version. My guess is that the change occurred between 1.8 and 1.10.

@WardF
Copy link
Member

WardF commented Jan 28, 2019

Merged in modifications from master, seeing a failure in builds using mpicc. Going to add a single instance (non comprehensive for now) of parallel builds to travis to catch compilation errors, will follow up here with more info as I go back and sort it out.

@WardF
Copy link
Member

WardF commented Jan 29, 2019

Seeing failures in the following tests when running which mpicc provided by mpich.

The following tests FAILED:
	 46 - nc_test_run_pnetcdf_test (Failed)
	 47 - nc_test_tst_formatx_pnetcdf (Failed)
	 50 - nc_test_tst_small (Failed)
	 52 - nc_test_tst_norm (Failed)
	 54 - nc_test_tst_nofill (Failed)
	 68 - nc_test (Child aborted)
	136 - nc_test4_tst_atts3 (Failed)

Details available at http://cdash.unidata.ucar.edu/viewTest.php?onlyfailed&buildid=7195

@WardF WardF added this to the 4.7.0 milestone Jan 29, 2019
@DennisHeimbigner
Copy link
Collaborator Author

I think I forgot to enable pnetcdf. Without pnetcdf, I get no failures.

@WardF
Copy link
Member

WardF commented Jan 31, 2019

I've updated the travis images so that the proper errors are being reported now.

So, fixed the following:
1. Forgot to check for NC_FORMATX_PNETCDF case
   in one of the switches in NC_infermodel.
2. Accidentally turned on both the NC_64BIT_OFFSET
   and the NC_64BIT_DATA mode flags.
@DennisHeimbigner
Copy link
Collaborator Author

Added fixes for the parallel case.

@WardF WardF self-assigned this Mar 19, 2019
@WardF WardF modified the milestones: 4.7.0, 4.6.4 Mar 19, 2019
@WardF WardF merged commit 6b470b2 into master Mar 19, 2019
@WardF WardF deleted the byterange.dmh branch March 19, 2019 20:04
conflictset(MF,model->format,NC_FORMAT_64BIT_DATA);
}
if(fIsSet(cmode,NC_NETCDF4)) {
conflictset(MF,model->format,NC_FORMAT_NETCDF4);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm looking at an issue where passing NC_NOWRITE | NC_64BIT_OFFSET | NC_NETCDF4 | NC_CLASSIC_MODEL flags worked in 4.6.2, but fails in 4.7.0 in this function. It seems to be detecting that we have the NC_FORMAT_64BIT_OFFSET as the format and then fails here because the format has already been set. Is this intended? Should it have worked before?

@DennisHeimbigner
Copy link
Collaborator Author

I would say that since NC_64BIT_OFFSET => classic format
that also specifying NC_NETCDF4 should be an error.

@mathstuf
Copy link
Contributor

mathstuf commented Jun 7, 2019

Thanks. Removing the NC_64BIT_OFFSET flag worked with the tests we have.

kwrobot pushed a commit to Kitware/VTK that referenced this pull request Jun 7, 2019
NetCDF 4.7.0 now detects this as an error because the mode is requesting
a 64-bit offset format and a netcdf4 format and errors due to a
conflicting format being requested. Upstream says that mixing these is
an error.

See: Unidata/netcdf-c#1267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

netcdf lib open in memory question
3 participants