Skip to content

Commit 42c5cd4

Browse files
committed
start implementing https functionality
1 parent 0995d0d commit 42c5cd4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

activestorage/active.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import concurrent.futures
22
import os
3+
import fsspec
34
import numpy as np
45
import pathlib
56
import urllib
@@ -50,6 +51,18 @@ def load_from_s3(uri, storage_options=None):
5051
return ds
5152

5253

54+
def load_from_https(uri):
55+
"""
56+
Load a Dataset from a netCDF4 file on an https server (NGINX).
57+
"""
58+
#TODO need to test if NGINX server behind https://
59+
fs = fsspec.filesystem('http')
60+
http_file = fs.open(uri, 'rb')
61+
ds = pyfive.File(http_file)
62+
print(f"Dataset loaded from https with Pyfive: {uri}")
63+
return ds
64+
65+
5366
def get_missing_attributes(ds):
5467
""""
5568
Load all the missing attributes we need from a netcdf file
@@ -187,6 +200,8 @@ def __load_nc_file(self):
187200
nc = pyfive.File(self.uri)
188201
elif self.storage_type == "s3":
189202
nc = load_from_s3(self.uri, self.storage_options)
203+
elif self.storage_type == "https":
204+
nc = load_from_https(self.uri)
190205
self.filename = self.uri
191206
self.ds = nc[ncvar]
192207

0 commit comments

Comments
 (0)