-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Flagging #37
Changes from 1 commit
41701da
2eebcf6
a7f16bd
1f7518d
b9a3b62
593af4e
05099e7
96543e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
import sys | ||
import analytics | ||
|
||
|
||
INITIAL_PORT_VALUE = int(os.getenv( | ||
'GRADIO_SERVER_PORT', "7860")) # The http server will try to open on port 7860. If not available, 7861, 7862, etc. | ||
TRY_NUM_PORTS = int(os.getenv( | ||
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed it to |
||
analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy" | ||
analytics_url = 'https://api.gradio.app/' | ||
|
||
|
@@ -187,20 +185,17 @@ def do_POST(self): | |
data_string = self.rfile.read( | ||
int(self.headers["Content-Length"])) | ||
msg = json.loads(data_string) | ||
flag_dir = os.path.join(FLAGGING_DIRECTORY, | ||
str(interface.flag_hash)) | ||
os.makedirs(flag_dir, exist_ok=True) | ||
os.makedirs(interface.flagging_dir, exist_ok=True) | ||
output = {'inputs': [interface.input_interfaces[ | ||
i].rebuild_flagged( | ||
flag_dir, msg['data']['input_data']) for i | ||
interface.flagging_dir, msg['data']['input_data']) for i | ||
in range(len(interface.input_interfaces))], | ||
'outputs': [interface.output_interfaces[ | ||
i].rebuild_flagged( | ||
flag_dir, msg['data']['output_data']) for i | ||
in range(len(interface.output_interfaces))], | ||
'message': msg['data']['message']} | ||
interface.flagging_dir, msg['data']['output_data']) for i | ||
in range(len(interface.output_interfaces))]} | ||
|
||
with open(os.path.join(flag_dir, FLAGGING_FILENAME), 'a+') as f: | ||
with open(os.path.join(interface.flagging_dir, FLAGGING_FILENAME), 'a+') as f: | ||
f.write(json.dumps(output)) | ||
f.write("\n") | ||
|
||
|
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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