Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Refactor predict output #579

Merged
merged 6 commits into from
Oct 31, 2019

Conversation

suttang
Copy link
Contributor

@suttang suttang commented Oct 30, 2019

Motivation and Context

This PR related to #480
To refactor the code around predict result output, we need to create OutputWriter and OutputParser I think.

In this PR, I created OutputWriter class.

Description

  • deleted save functions from predict.py
  • created output writer class and test

How has this been tested?

  1. Compare output files from master and this PR's one.
  2. make test

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / Optimization (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@suttang suttang requested a review from iizukak October 30, 2019 10:05
@suttang suttang self-assigned this Oct 30, 2019
@blueoil-butler blueoil-butler bot added the CI: auto-run Run CI automatically label Oct 30, 2019
Copy link
Member

@iizukak iizukak left a comment

Choose a reason for hiding this comment

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

@suttang
Nice PR!!
Please check few comments.

numpy array, JSON, and images if you want.

Args:
dest (str): paht to save file
Copy link
Member

Choose a reason for hiding this comment

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

typo in paht .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

save_materials(dest, materials, step)


def save_npy(dest, outputs, step):
Copy link
Member

Choose a reason for hiding this comment

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

Why these function are not method of OutputWriter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer "Don't put in a method if you don't need it" mentality.
These functions don't need the state of OutputWriter.
IMO, This makes these functions independent and easier to test.

Copy link
Member

Choose a reason for hiding this comment

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

I see.

print("save json: {}".format(filepath))


def save_materials(dest, materials, step):
Copy link
Member

Choose a reason for hiding this comment

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

save_materials looks general name. save_images is not enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One day we will come to deal with tasks other than images.
Named for that time.
If not, I will fix.

Copy link
Member

Choose a reason for hiding this comment

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

I see. To the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Go to the future!

Copy link
Member

@iizukak iizukak left a comment

Choose a reason for hiding this comment

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

Ownership Approval.

@suttang suttang requested a review from tsawada October 31, 2019 04:50
Copy link
Contributor

@tsawada tsawada left a comment

Choose a reason for hiding this comment

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

LGTM, Approval

with open(filepath, "w") as f:
f.write(json)

print("save json: {}".format(filepath))
Copy link
Contributor

Choose a reason for hiding this comment

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

we should not print debugging information.



@pytest.fixture
def temp_dir():
Copy link
Contributor

Choose a reason for hiding this comment

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

with TemporaryDirectory() as t:
    yield t.name

@suttang suttang merged commit 75c39a4 into blue-oil:master Oct 31, 2019
@suttang suttang deleted the refactor/predict-output-writer branch October 31, 2019 08:17
@iizukak iizukak added this to the v0.14.0 milestone Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants