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

refactor: clean up GraphDataset and Trainer class #255

Merged
merged 36 commits into from Nov 28, 2022

Conversation

DaniBodor
Copy link
Collaborator

@DaniBodor DaniBodor commented Nov 25, 2022

  • raise error if dataset_train/dataset_val/dataset_test are not compatible
    • add unit tests to test_trainer to check that it works
  • raise error if no target exists
    • add unit tests to test_trainer to check that it works
  • adhere to python style
    • rename trainer and dataset modules (no capitals)
    • rename GraphDataset class (former HDF5DataSet)
    • rename parameters to no caps to comply and methods to comply with python style
    • add type hinting and clean up docstrings for GraphDataset and Trainer classes
  • renamed some attributes to clarify what they do
  • make all (most?) inputs of Trainer attributes instead of calling them explicitly
  • reorder inputs for GraphDataset and Trainer to a more logical flow
  • reorder GraphDataset and Trainer methods to better reflect temporal order of what happens internally
  • moved automatic setting of task (based on target) into a method to clean up the GraphDataset init

closes: #152 and #194
also partially addresses: #236 (the rest will move to #234)

deeprankcore/trainer.py Outdated Show resolved Hide resolved
Comment on lines 230 to 234
if any(key in grp for key in ("internal_edge_index", "internal_edge_data")):
warnings.warn(
"""Internal edges are not supported anymore.
You should probably prepare the hdf5 file
with a more up to date version of this software.""", DeprecationWarning)
"""Internal edges are not supported anymore.\n
You should probably prepare hdf5 files with a more up to date version of this software.""",
DeprecationWarning)
Copy link
Collaborator Author

@DaniBodor DaniBodor Nov 25, 2022

Choose a reason for hiding this comment

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

do we still need this warning or can it go?
If it stays, I'll reword the warning.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can leave it for now, just in case. This warning was placed by Coos for older hdf5 files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@cbaakman is this warning still necessary?

CHANGELOG.md Outdated Show resolved Hide resolved
@DaniBodor DaniBodor linked an issue Nov 25, 2022 that may be closed by this pull request
4 tasks
@DaniBodor DaniBodor marked this pull request as ready for review November 25, 2022 13:19
@DaniBodor DaniBodor linked an issue Nov 25, 2022 that may be closed by this pull request
Copy link
Collaborator

@gcroci2 gcroci2 left a comment

Choose a reason for hiding this comment

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

Finally at the end of this :-) I have only really minor suggestions

deeprankcore/dataset.py Outdated Show resolved Hide resolved
deeprankcore/trainer.py Outdated Show resolved Hide resolved
deeprankcore/trainer.py Outdated Show resolved Hide resolved

self.complete_exporter = ConciseOutputExporter(self.output_dir)
self.neuralnet = neuralnet
Copy link
Collaborator

Choose a reason for hiding this comment

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

Recall that neuralnet argument so far is a class, and here you're assigning it to an attribute without properly initializing it. I would suggest declaring here model attribute = None, and using neuralnet later on as in the original code. It's still possible to access the details of the neural network through model attribute, without messing with the class itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not clear to me. Maybe we can sit down and you explain what you mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will be taken care of in #234

@DaniBodor DaniBodor merged commit 31d7f60 into main Nov 28, 2022
@DaniBodor DaniBodor deleted the 236_clean_dataset_dbodor branch November 28, 2022 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants