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

Flagging #37

Merged
merged 8 commits into from
Jul 30, 2020
Merged

Flagging #37

merged 8 commits into from
Jul 30, 2020

Conversation

aliabd
Copy link
Collaborator

@aliabd aliabd commented Jul 27, 2020

No description provided.

@aliabd aliabd requested a review from abidlabs July 28, 2020 16:58
gradio/inputs.py Outdated
@@ -63,6 +63,11 @@ def get_shortcut_implementations(cls):
"""
return {}

def rebuild_flagged(self, dir, msg):
Copy link
Member

Choose a reason for hiding this comment

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

We probably want to use this method for more than just flagging. Any time we have an image / sample in the front end, and we want to convert it back to a Python object, we should use this method. So I actually think a better name for this might just be rebuild or pythonify or deprocess

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed name to rebuild

@@ -36,7 +36,7 @@
ASSOCIATION_PATH_IN_STATIC = "static/apple-app-site-association"
ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association"

FLAGGING_DIRECTORY = 'static/flagged/'
FLAGGING_DIRECTORY = 'flagged/'
Copy link
Member

Choose a reason for hiding this comment

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

This can be the default, but I would allow this to be overridden with a parameter in the Interface class.

Copy link
Collaborator Author

@aliabd aliabd Jul 29, 2020

Choose a reason for hiding this comment

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

Added flagging_dir parameter to Interface, set to "flagged" by default

gradio/inputs.py Outdated
@@ -290,6 +295,16 @@ def process_example(self, example):
else:
return example

def rebuild_flagged(self, dir, msg):
Copy link
Member

Choose a reason for hiding this comment

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

msg is not used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

msg here is what I named the input data I get from the api. Changed the name to data. This isn't the old message feature

@@ -56,12 +56,12 @@ var io_master_template = {
this.target.find(".output_interfaces").css("opacity", 1);
}
},
flag: function(message) {
flag: function() {
Copy link
Member

Choose a reason for hiding this comment

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

Can we just remove message if we're not using it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's no message anymore, this change was to remove it. See above for msg/message confusion.

@@ -121,6 +123,18 @@ def get_output_instance(iface):
except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this.
pass

if self.allow_flagging:
Copy link
Member

@abidlabs abidlabs Jul 28, 2020

Choose a reason for hiding this comment

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

I think it's more elegant to come up with the directory name in 1 step rather than 2. So something like:

base_dir_name = "-".join(self.title.split(" "))
index = 0
while os.path.exists(os.path.join(FLAGGING_DIRECTORY, base_dir_name , index)):
    index += 1
dir_name = os.path.join(FLAGGING_DIRECTORY, base_dir_name , index)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To be clear join will add a / separator so it would be "FLAGGING_DIRECTORY/base_dir_name/index". I thought it would be too nested so I wrote similar code that produces "FLAGGING_DIRECTORY/base_dir_name_index"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or do you think nested is better?

Copy link
Member

Choose a reason for hiding this comment

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

Ah good point, no I think what you wrote is better

@@ -36,8 +35,7 @@
ASSOCIATION_PATH_IN_STATIC = "static/apple-app-site-association"
ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association"

FLAGGING_DIRECTORY = 'flagged/'
FLAGGING_FILENAME = 'data.txt'
FLAGGING_FILENAME = 'flagged.txt'
Copy link
Member

Choose a reason for hiding this comment

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

Again, this is fine for the default (although I would have probably used something like log.txt), but consider allowing user to override

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed it to log.txt, but haven't added it as a parameter. We're starting to have too many parameters in Interface right now. Do you think that's an annoyance?

gradio/inputs.py Outdated
"""
All interfaces should define a method that rebuilds the flagged input when it's passed back (i.e. rebuilds image from base64)
"""
pass
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it makes sense to define a default method? Or are you planning on implementing this method for every AbstractInput and AbstractOutput?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a default method, you are commenting on an outdated commit. By default the data is returned with no processing. (Like with Text)

gradio/inputs.py Outdated
@@ -67,7 +67,7 @@ def rebuild_flagged(self, dir, msg):
"""
All interfaces should define a method that rebuilds the flagged input when it's passed back (i.e. rebuilds image from base64)
"""
pass
return msg
Copy link
Member

Choose a reason for hiding this comment

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

I thought msg is always blank?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above for msg/message confusion. changed msg to data.

@@ -48,7 +48,7 @@ def rebuild_flagged(self, dir, msg):
"""
All interfaces should define a method that rebuilds the flagged input when it's passed back (i.e. rebuilds image from base64)
"""
pass
return msg
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above

@abidlabs abidlabs merged commit 480591a into master Jul 30, 2020
@abidlabs abidlabs deleted the aliabd/flagging branch August 5, 2020 17:43
abidlabs pushed a commit that referenced this pull request Oct 12, 2021
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