From ae5a0c7fadac1ae209065bca1e241641d01b3723 Mon Sep 17 00:00:00 2001 From: Anton Kollmats Date: Tue, 15 Feb 2022 11:14:47 +0100 Subject: [PATCH 1/3] fixes PermissionError for non-writable flagging path --- gradio/interface.py | 2 +- test/test_flagging.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gradio/interface.py b/gradio/interface.py index b50025e9f1..fe1c7534e2 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -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() diff --git a/test/test_flagging.py b/test/test_flagging.py index e5b179bfda..4a42e8afc8 100644 --- a/test/test_flagging.py +++ b/test/test_flagging.py @@ -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() From 970403dd917d2d41e345a45726d2c8e9561f7e2b Mon Sep 17 00:00:00 2001 From: Dominic Rampas <61938694+dome272@users.noreply.github.com> Date: Tue, 15 Feb 2022 21:13:00 +0100 Subject: [PATCH 2/3] Create de.json --- ui/packages/app/public/lang/de.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ui/packages/app/public/lang/de.json diff --git a/ui/packages/app/public/lang/de.json b/ui/packages/app/public/lang/de.json new file mode 100644 index 0000000000..ef2e2d1289 --- /dev/null +++ b/ui/packages/app/public/lang/de.json @@ -0,0 +1,18 @@ +{ + "interface": { + "submit": "Absenden", + "clear": "Löschen", + "interpret": "Ersteller", + "flag": "Flag", + "examples": "Beispiele", + "drop_image": "Bild hier ablegen", + "drop_video": "Video hier ablegen", + "drop_audio": "Audio hier ablegen", + "drop_file": "Datei hier ablegen", + "drop_csv": "CSV Datei hier ablegen", + "or": "oder", + "click_to_upload": "Hochladen", + "view_api": "API anschauen", + "built_with_Gradio": "Mit Gradio erstellt" + } +} From d93f6cef73ff87a776599fc4f23bdb816048cd61 Mon Sep 17 00:00:00 2001 From: "Omar U. Espejel" Date: Tue, 15 Feb 2022 15:40:48 -0500 Subject: [PATCH 3/3] Corrections in Spanish support I edited sentences to adapt them to the way they are commonly written in Spanish :D --- ui/packages/app/public/lang/es.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/packages/app/public/lang/es.json b/ui/packages/app/public/lang/es.json index 04d250d986..b9848b793e 100644 --- a/ui/packages/app/public/lang/es.json +++ b/ui/packages/app/public/lang/es.json @@ -5,14 +5,14 @@ "interpret": "Interpretar", "flag": "Avisar", "examples": "Ejemplos", - "drop_image": "Coloque la Imagen Aquí", - "drop_video": "Coloque la Video Aquí", - "drop_audio": "Coloque la Audio Aquí", - "drop_file": "Coloque la Archivo Aquí", - "drop_csv": "Coloque el CSV Aquí", + "drop_image": "Coloque la imagen aquí", + "drop_video": "Coloque el video aquí", + "drop_audio": "Coloque el audio aquí", + "drop_file": "Coloque el archivo aquí", + "drop_csv": "Coloque el CSV aquí", "or": "o", - "click_to_upload": "Haga Clic para Cargar", - "view_api": "Para ver la API", + "click_to_upload": "Haga click para cargar", + "view_api": "Ver la API", "built_with_Gradio": "Construido con Gradio" } }