Skip to content

GSLA - update handler to handle non gzipped files#264

Merged
mhidas merged 2 commits into
masterfrom
gslaUpdate
Apr 21, 2021
Merged

GSLA - update handler to handle non gzipped files#264
mhidas merged 2 commits into
masterfrom
gslaUpdate

Conversation

@lbesnard
Copy link
Copy Markdown
Contributor

Add logic to transform a received NetCDF file into a .nc.gz

historically, files were always sent as *.nc.gz. But as of April 2021, files might be pushed as *.nc
To be consistent with the existing dataset, and gogoduck, we transform this .nc into a .nz.gz

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2021

Codecov Report

Merging #264 (c2e1e13) into master (9d37dfe) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #264      +/-   ##
==========================================
+ Coverage   87.98%   88.04%   +0.06%     
==========================================
  Files          50       50              
  Lines        3221     3229       +8     
  Branches      536      537       +1     
==========================================
+ Hits         2834     2843       +9     
  Misses        243      243              
+ Partials      144      143       -1     
Impacted Files Coverage Δ
aodndata/gsla/handler.py 94.00% <100.00%> (+1.60%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d37dfe...c2e1e13. Read the comment docs.

@lbesnard
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Contributor

@mhidas mhidas left a comment

Choose a reason for hiding this comment

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

I just made a few suggestions to simplify handling of input file and file collection using recently added aodncore functionality.

Comment thread aodndata/gsla/handler.py Outdated
Comment on lines +82 to +84
netcdf_collection = self.file_collection.filter_by_attribute_id('file_type', FileType.NETCDF)
netcdf_file = netcdf_collection[0]
netcdf_file.publish_type = PipelineFilePublishType.NO_ACTION
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you already know it's a single netCDF file being handled, you can do this more simply...

Suggested change
netcdf_collection = self.file_collection.filter_by_attribute_id('file_type', FileType.NETCDF)
netcdf_file = netcdf_collection[0]
netcdf_file.publish_type = PipelineFilePublishType.NO_ACTION
self.file_collection.set_publish_types(PipelineFilePublishType.NO_ACTION)

Comment thread aodndata/gsla/handler.py Outdated
netcdf_file = netcdf_collection[0]
netcdf_file.publish_type = PipelineFilePublishType.NO_ACTION

gzip_path = os.path.join(self.temp_dir, os.path.basename(self.input_file + '.gz'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's a shortcut available here too... (file_basename property)

Suggested change
gzip_path = os.path.join(self.temp_dir, os.path.basename(self.input_file + '.gz'))
gzip_path = os.path.join(self.temp_dir, self.file_basename + '.gz')

Comment thread aodndata/gsla/handler.py Outdated
Comment on lines +91 to +94
netcdf_file_gz = PipelineFile(gzip_path, file_update_callback=self._file_update_callback)
netcdf_file_gz.publish_type = PipelineFilePublishType.HARVEST_UPLOAD

self.file_collection.add(netcdf_file_gz)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And again... (see aodn/python-aodncore#209)

Suggested change
netcdf_file_gz = PipelineFile(gzip_path, file_update_callback=self._file_update_callback)
netcdf_file_gz.publish_type = PipelineFilePublishType.HARVEST_UPLOAD
self.file_collection.add(netcdf_file_gz)
self.add_to_collection(gzip_path, publish_type=PipelineFilePublishType.HARVEST_UPLOAD)

@lbesnard
Copy link
Copy Markdown
Contributor Author

thanks @mhidas I followed your suggestions

@mhidas
Copy link
Copy Markdown
Contributor

mhidas commented Apr 21, 2021

👍 I haven't really looked at the unittests, but they all seem to be passing, so should be ok. Is this ready to merge then?

@lbesnard
Copy link
Copy Markdown
Contributor Author

it is ! thanks. oh yeah I looked at them quite a lot!

@mhidas mhidas merged commit 01adcf2 into master Apr 21, 2021
@mhidas mhidas deleted the gslaUpdate branch April 21, 2021 04:21
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.

2 participants