Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Conversation

@peterdudfield
Copy link
Contributor

Pull Request

Description

add tests for manager

  • test that checks batches are made
  • test that checks config is saved

Want to do this before #341

Fixes #324

How Has This Been Tested?

normal unit test

  • addition ones for this PR
  • No
  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@peterdudfield
Copy link
Contributor Author

Tests pass - locally - strange ....

Copy link
Contributor

@JackKelly JackKelly left a comment

Choose a reason for hiding this comment

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

Looks good!

A few minor comments...

If you're using logger.warning so the log messages appear during unittests then I think there is a way to set the log level to, say, debug during tests (but I can't remember exactly how to do that!)

# Split locations per example into batches:
n_batches = len(spatial_and_temporal_locations_of_each_example) // batch_size
locations_for_batches = []
logger.warning("xxxxx")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this warning still required? 🙂

n_batches = len(spatial_and_temporal_locations_of_each_example) // batch_size
locations_for_batches = []
logger.warning("xxxxx")
logger.warning(n_batches)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this warning a bit more verbose?

for n_batches_processed, locations_for_batch in enumerate(locations_for_batches):
batch_idx = idx_of_first_batch + n_batches_processed
logger.debug(f"{self.__class__.__name__} creating batch {batch_idx}!")
logger.warning(f"{self.__class__.__name__} creating batch {batch_idx}!")
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if I've misunderstood but why does this message need to be a warning?

# Save batch to disk.
netcdf_filename = path_to_write_to / nd_utils.get_netcdf_filename(batch_idx)
batch.to_netcdf(netcdf_filename)
logger.warning(f"Save file to {netcdf_filename}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: Does this message really need to be a warning?

filesystem = get_filesystem(dst_path)
filesystem.put(str(local_path), dst_path, recursive=True)

_LOG.warning(f"moving files from {local_path} to {dst_path}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be a warning?


_LOG.warning(f"moving files from {local_path} to {dst_path}")

_LOG.warning(get_all_filenames_in_path(local_path))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make these two messages a bit more verbose (or maybe remove these two messages?) Also, do these need to be warnings?

filesystem.put(str(local_path) + "/", str(dst_path) + "/", recursive=True)
delete_all_files_in_temp_path(local_path)

_LOG.warning(get_all_filenames_in_path(local_path))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above :)

data_source.create_batches,
print(executor)
# future = executor.submit(
logger.warning("Making batches")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these need to be warnings?

black
pre-commit
fsspec
fsspec==2021.7.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Ooh, interesting, are we sure we can't use more recent versions of fsspec? A few days ago, there was a bug (I think) in fsspec which forced pip to install an ancient version of gscfs but that appears fixed now (if that's what make you pin fsspec to version 2021.7.0?

@peterdudfield
Copy link
Contributor Author

peterdudfield commented Nov 11, 2021

Hey @JackKelly sorry i closed this PR and move to #363

I was debugging using CI as tests worked on my laptop. It turns out the fix was to use fsspec.copy not fsspec.put

@peterdudfield peterdudfield deleted the issue/3422-manger-test branch November 11, 2021 10:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document new architecture (including a diagram)

3 participants