diff --git a/gradio/interface.py b/gradio/interface.py index fe1c7534e2..fafcc1076b 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 != "never": + 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 4a42e8afc8..3837907f94 100644 --- a/test/test_flagging.py +++ b/test/test_flagging.py @@ -71,23 +71,21 @@ 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') - + nonwritable_path = os.path.join(tmpdirname, "flagging_dir") + io = gr.Interface( lambda x: x, "text", "text", allow_flagging="never", - flagging_dir=nonwritable_path + 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__": diff --git a/ui/packages/app/public/lang/fr.json b/ui/packages/app/public/lang/fr.json new file mode 100644 index 0000000000..372c75c52e --- /dev/null +++ b/ui/packages/app/public/lang/fr.json @@ -0,0 +1,19 @@ +{ + "interface": { + "submit": "Soumettre", + "clear": "Nettoyer", + "interpret": "Interpréter", + "flag": "Signaler", + "examples": "Exemples", + "drop_image": "Déposer l'Image Ici", + "drop_video": "Déposer la Vidéo Ici", + "drop_audio": "Déposer l'Audio Ici", + "drop_file": "Déposer le Fichier Ici", + "drop_csv": "Déposer le CSV Ici", + "or": "ou", + "click_to_upload": "Cliquer pour Télécharger", + "view_api": "Voir l'API", + "built_with_Gradio": "Conçu avec Gradio" + } + } + \ No newline at end of file diff --git a/ui/packages/app/public/lang/he.json b/ui/packages/app/public/lang/he.json new file mode 100644 index 0000000000..53f9735861 --- /dev/null +++ b/ui/packages/app/public/lang/he.json @@ -0,0 +1,18 @@ +{ + "interface": { + "submit": "שלח", + "clear": "נקה", + "interpret": "לפרש", + "flag": "סמן", + "examples": "דוגמות", + "drop_image": "גרור קובץ תמונה לכאן", + "drop_video": "גרור קובץ סרטון לכאן", + "drop_audio": "גרור לכאן קובץ שמע", + "drop_file": "גרור קובץ לכאן", + "drop_csv": "גרור csv קובץ לכאן", + "or": "או", + "click_to_upload": "לחץ כדי להעלות", + "view_api": "צפה ב API", + "built_with_Gradio": "בנוי עם גרדיו" + } + } \ No newline at end of file diff --git a/ui/packages/app/public/lang/zh_TW.json b/ui/packages/app/public/lang/zh_TW.json new file mode 100644 index 0000000000..b6af49d578 --- /dev/null +++ b/ui/packages/app/public/lang/zh_TW.json @@ -0,0 +1,18 @@ +{ + "interface": { + "submit": "提交", + "clear": "清除", + "interpret": "解釋", + "flag": "Flag", + "examples": "範例", + "drop_image": "刪除圖片", + "drop_video": "刪除影片", + "drop_audio": "刪除音頻", + "drop_file": "刪除檔案", + "drop_csv": "刪除CSV", + "or": "或", + "click_to_upload": "點擊上傳", + "view_api": "查看API", + "built_with_Gradio": "使用Gradio構建" + } +} \ No newline at end of file diff --git a/ui/packages/app/src/components/input/DataFrame/DataFrame.svelte b/ui/packages/app/src/components/input/DataFrame/DataFrame.svelte index 179fdec9da..8918728b63 100644 --- a/ui/packages/app/src/components/input/DataFrame/DataFrame.svelte +++ b/ui/packages/app/src/components/input/DataFrame/DataFrame.svelte @@ -1,13 +1,11 @@ -

{label}

-
{ - it("handle B", () => { + test("handle B", () => { assert.equal(prettyBytes(10), "10.0 B"); }); - it("handles KB", () => { + test("handles KB", () => { assert.equal(prettyBytes(1_300), "1.3 KB"); }); - it("handles MB", () => { + test("handles MB", () => { assert.equal(prettyBytes(1_300_000), "1.2 MB"); }); - it("handles GB", () => { + test("handles GB", () => { assert.equal(prettyBytes(1_300_000_123), "1.2 GB"); }); - it("handles PB", () => { + test("handles PB", () => { assert.equal(prettyBytes(1_300_000_123_000), "1.2 PB"); }); }); + +describe("deepCopy", () => { + test("handle arrays", () => { + const array = [1, 2, 3]; + const copy = deepCopy(array); + assert.ok(array !== copy); + assert.deepEqual(array, copy); + }); + + test("handle objects", () => { + const obj = { a: 1, b: 2, c: 3 }; + const copy = deepCopy(obj); + assert.ok(obj !== copy); + assert.deepEqual(obj, copy); + }); + + test("handle complex structures", () => { + const obj = { + a: 1, + b: { + a: 1, + b: { + a: 1, + b: { a: 1, b: 2, c: 3 }, + c: [ + 1, + 2, + { a: 1, b: { a: 1, b: { a: 1, b: 2, c: 3 }, c: [1, 2, 3] } } + ] + }, + c: 3 + }, + c: 3 + }; + const copy = deepCopy(obj); + assert.ok(obj !== copy); + assert.deepEqual(obj, copy); + }); +}); + +describe("randInt", () => { + test("returns a random number", () => { + assert.typeOf(randInt(0, 10), "number"); + }); + + test("respects min and max", () => { + const n = randInt(0, 10); + assert.ok(n >= 0 && n <= 10); + }); + + test("respects min and max when negative", () => { + const n = randInt(-100, -10); + assert.ok(n > -100 && n < -10); + }); +}); + +describe("getNextColor", () => { + test("returns a color", () => { + assert.equal(getNextColor(0), "rgba(255, 99, 132, 1)"); + }); + + test("returns a color when index is very high", () => { + assert.ok( + getNextColor(999999999).match( + /rgba\([0-9]{1,3}, [0-9]{1,3}, [0-9]{1,3}, [0-9]\)/ + ) + ); + }); +}); diff --git a/ui/packages/app/src/components/utils/helpers.ts b/ui/packages/app/src/components/utils/helpers.ts index 1b73115888..2bc224c646 100644 --- a/ui/packages/app/src/components/utils/helpers.ts +++ b/ui/packages/app/src/components/utils/helpers.ts @@ -15,8 +15,7 @@ export function randInt(min: number, max: number): number { return Math.floor(Math.random() * (max - min) + min); } -export const getNextColor = (index: number, alpha?: number): string => { - alpha = alpha || 1; +export const getNextColor = (index: number, alpha: number = 1): string => { let default_colors = [ [255, 99, 132], [54, 162, 235], diff --git a/ui/packages/app/src/i18n.js b/ui/packages/app/src/i18n.js index 1f5f26aa15..8c700aec1e 100644 --- a/ui/packages/app/src/i18n.js +++ b/ui/packages/app/src/i18n.js @@ -1,11 +1,15 @@ import { addMessages, init, getLocaleFromNavigator } from "svelte-i18n"; import en from "../public/lang/en.json"; import es from "../public/lang/es.json"; +import fr from "../public/lang/fr.json"; import ur from "../public/lang/ur.json"; +import zh_TW from "../public/lang/zh_TW.json"; addMessages("en", en); addMessages("es", es); +addMessages("fr", fr); addMessages("ur", ur); +addMessages("zh_TW", zh_TW); export function setupi18n() { init({