{"id":13501537,"url":"https://github.com/Miserlou/Fashion","last_synced_at":"2025-03-29T09:30:45.821Z","repository":{"id":136420222,"uuid":"211556735","full_name":"Miserlou/Fashion","owner":"Miserlou","description":"Pythonic OpenFaaS. aka `python-openfaas`.","archived":false,"fork":false,"pushed_at":"2019-10-18T13:45:42.000Z","size":10,"stargazers_count":33,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-27T21:31:35.696Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/Miserlou/Fashion","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Miserlou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-09-28T20:17:19.000Z","updated_at":"2024-01-04T16:38:12.000Z","dependencies_parsed_at":"2024-01-16T10:36:44.707Z","dependency_job_id":"4351ef67-ee2b-426b-af32-366be6fe380b","html_url":"https://github.com/Miserlou/Fashion","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miserlou%2FFashion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miserlou%2FFashion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miserlou%2FFashion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miserlou%2FFashion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miserlou","download_url":"https://codeload.github.com/Miserlou/Fashion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222481502,"owners_count":16991463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:01:40.943Z","updated_at":"2024-10-31T20:31:38.492Z","avatar_url":"https://github.com/Miserlou.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://i.imgur.com/DpAUHQv.png\" alt=\"Fashion: python openfaas\" /\u003e\n\u003c/p\u003e\n\n# Fashion [![Python 3](https://img.shields.io/badge/Python-3-brightgreen.svg)](https://github.com/Miserlou/Fashion)\n### aka, python-openfaas\n\n_Work in progress!_\n\n**Fashion** is a library for using [OpenFaaS](https://openfaas.com) functions in a Pythonic way. Fashion functions run inside their own Docker containers in your cluster, but act like local functions in your application's code! **Cool!**\n\nFor instance, let's imagine that we've installed the `figlet` function from the OpenFaaS function store. To call it from our application, we can simply:\n\n```python\nfrom fashion import figlet\nhi = figlet(\"Hello, world!\")\n#  _   _      _ _                             _     _ _\n# | | | | ___| | | ___    __      _____  _ __| | __| | |\n# | |_| |/ _ \\ | |/ _ \\   \\ \\ /\\ / / _ \\| '__| |/ _` | |\n# |  _  |  __/ | | (_) |   \\ V  V / (_) | |  | | (_| |_|\n# |_| |_|\\___|_|_|\\___( )   \\_/\\_/ \\___/|_|  |_|\\__,_(_)\n#                    |/\n```\n\nFashion doesn't need any prior knowledge of the OpenFaas function, you can simply call it as if it were a local function!\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Ordinary Usage](#ordinary-usage)\n  - [Async](#async)\n    - [Callbacks](#callbacks)\n    - [Instance Type Limiting / Automatic Cost Optimization](#instance-type-limiting--automatic-cost-optimization)\n  - [Other OpenFaaS utilities](#other-openfaas-utilities)\n  - [Settings](#settings)\n- [Related Projects](#related-projects)\n- [TODO](#todo)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\n(Coming [soon](https://github.com/pypa/warehouse/issues/6725)!)\n```\npip install fashion\n```\n\n## Usage\n\n### Ordinary Usage\n\nFashion is very easy to use, just import your OpenFaaS function as if it were native!\n\nFor instance:\n```python\nfrom fashion import leftpad\nleftpad(\"Hello!\") # \"      Hello!\"\n```\n\nAlternately, you can use Fashion's `trigger` function directly, like so:\n\n```python\nimport fashion\nfashion.trigger(\"leftpad\", \"Hello!\") #\"      Hello!\"\n```\nFunctions can be chained together without friction:\n\n```python\nfrom fashion import leftpad, figlet\nfiglet(leftpad(\"Hello!\"))\n#  _                _   _      _ _       _ _\n# ( )              | | | | ___| | | ___ | ( )\n# |/               | |_| |/ _ \\ | |/ _ \\| |/\n#                  |  _  |  __/ | | (_) |_|\n#                  |_| |_|\\___|_|_|\\___/(_)\n```\n\n### Async\n_(Still working on the interface for this, hang on a bit!)_\nSimilarly, you can use OpenFaaS functions asyncronously. To invoke an async function, import it with the prefix `async_` like so:\n\n```python\nfrom fashion import async_leftpad\nasync_leftpad(\"Hello!\") # \"6a3ae7fb-a8ee-4988-b7de-e3b81d1aed65\"\n```\n\nor the old fashioned way:\n\n```python\nimport fashion\nfashion.async_trigger(\"leftpad\", \"Hello!\") # \"6a3ae7fb-a8ee-4988-b7de-e3b81d1aed65\"\n```\n\n#### Callbacks\n\nAsync functions can have their results sent to callback URLs and other OpenFaaS functions. For example, you can send to a pastebin like this:\n\n```python\nfrom fashion import async_leftpad\nasync_leftpad(\"Hello\", callback_url=\"https://postb.in/b/1269724059086-0568930923473\")\n```\n\nor to another OpenFaaS function like this:\n\n```python\nfrom fashion import async_leftpad\nasync_leftpad(\"Hello\", callback_function=\"figlet\")\n```\n\n#### Instance Type Limiting / Automatic Cost Optimization\n\nAn interesting use of this is limiting execution of functions to **certain instance types**. For instance, if this is included in an `update_model` function definition:\n\n```yaml\n#update_model.yml\n  [..]\n   constraints:\n     - \"node.labels.instance_type == gpu\"\n```\n\nThen you can write code which is **automatically cost-optimized** when it executes:\n\n```python\n# Runs on expensive GPU instance\nfrom fashion import update_model\n\n# Runs on cheap CPU instance\nfrom fashion import send_result_email\n\nresult = update_model(input)\nsend_email(result)\n# Email sent!\n```\n\n### Other OpenFaaS utilities\nYou can use Fashion to progromatically get information about all your OpenFaaS functions like so:\n\n```python\nimport fashion\nfashion.system_functions()\n```\n\n### Settings\nYou can configure your endpoints and other variables like so:\n\n```python\nimport fashion\n\nfashion.GATEWAY_URL = \"http://internal.network.location\"\nfashion.GATEWAY_PORT = 8081\nfashion.TIMEOUT_SECONDS = 30\n```\n\n## Related Projects\n * [Zappa](https://github.com/Miserlou/Zappa) - Python's Serverless Framework for AWS Lambda\n\n## TODO\n  * Tests\n  * Async\n  * Auth/HMAC settings\n  * Turn left__pad into left-pad invocation\n\n## License\n\n(C) Rich Jones 2019, MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMiserlou%2FFashion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMiserlou%2FFashion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMiserlou%2FFashion/lists"}