-
Notifications
You must be signed in to change notification settings - Fork 1
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
Solarsally #181
Solarsally #181
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just move the remote data dependency to a separate python file so it's not under unit test.
ds = xarray.open_dataset(io.BytesIO(ncfile_bytes)) | ||
|
||
# Initialize Google Cloud Storage client | ||
storage_client = storage.Client() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert the storage client code once debugging is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# Set the time using numpy.datetime64 for the expected format | ||
times[0] = numpy.datetime64("2010-02-02T18:00:00") | ||
# Close the NetCDF file and retrieve its contents as bytes | ||
memfile = ncfile.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on my understanding we retrieve the contents of ncfile using memfile.tobytes(). I'm concerned about memfile = ncfile.close(), because the close() method doesn’t return any value, leading to a potential error.
just be careful and consider not closing the NetCDF file until after assigned the necessary data for xarray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is with in-memory NetCDF files using netCDF4.Dataset, the behavior is a bit different than in typical file handling when the memory parameter is set to 1 (indicating in-memory storage). By specifying memory=1, we are instructing netCDF4 to create a file in memory instead of on disk, which changes the behavior of how the file is handled. now when we use "memfile = ncfile.close()" , instead of simply closing the file, the in-memory buffer (which contains the NetCDF file's contents) is returned. This buffer is similar to a file-like object, and we can then access the contents in bytes.
I have added two options for the testing file, one for GCP and another for fake data. I have also tested both of them locally, it works with no error. Now the same code handles both fake and real data. @Katsutoshii