mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-13 11:57:29 +08:00
Merge pull request #617 from kollmats/master
fixes PermissionError for non-writable flagging path
This commit is contained in:
commit
01f6869500
@ -684,7 +684,7 @@ class Interface:
|
||||
|
||||
if self.enable_queue is None:
|
||||
self.enable_queue = enable_queue
|
||||
if self.allow_flagging:
|
||||
if self.allow_flagging != "never":
|
||||
self.flagging_callback.setup(self.flagging_dir)
|
||||
|
||||
config = self.get_config_file()
|
||||
|
@ -67,5 +67,28 @@ class TestHuggingFaceDatasetSaver(unittest.TestCase):
|
||||
self.assertEqual(row_count, 2) # 3 rows written including header
|
||||
|
||||
|
||||
class TestDisableFlagging(unittest.TestCase):
|
||||
def test_flagging_no_permission_error_with_flagging_disabled(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||
os.chmod(tmpdirname, 0o444) # Make directory read-only
|
||||
nonwritable_path = os.path.join(
|
||||
tmpdirname, 'flagging_dir')
|
||||
|
||||
io = gr.Interface(
|
||||
lambda x: x,
|
||||
"text",
|
||||
"text",
|
||||
allow_flagging="never",
|
||||
flagging_dir=nonwritable_path
|
||||
)
|
||||
try:
|
||||
io.launch(prevent_thread_lock=True)
|
||||
except PermissionError:
|
||||
self.fail("launch() raised a PermissionError unexpectedly")
|
||||
|
||||
io.close()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user