{"id":18825436,"url":"https://github.com/grycap/oscar-gradio","last_synced_at":"2026-02-07T00:04:34.324Z","repository":{"id":149748430,"uuid":"544821681","full_name":"grycap/oscar-gradio","owner":"grycap","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-16T10:55:57.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-22T14:45:55.969Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/grycap.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-10-03T09:36:10.000Z","updated_at":"2025-05-16T10:56:01.000Z","dependencies_parsed_at":"2025-05-16T11:39:44.852Z","dependency_job_id":null,"html_url":"https://github.com/grycap/oscar-gradio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/grycap/oscar-gradio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Foscar-gradio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Foscar-gradio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Foscar-gradio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Foscar-gradio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grycap","download_url":"https://codeload.github.com/grycap/oscar-gradio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Foscar-gradio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29181265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T23:15:33.022Z","status":"ssl_error","status_checked_at":"2026-02-06T23:15:09.128Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-08T00:59:32.652Z","updated_at":"2026-02-07T00:04:34.308Z","avatar_url":"https://github.com/grycap.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# User Interfaces with Gradio for AI model inference in OSCAR services\n\n[Gradio](https://gradio.app) is a Python library for building user web interfaces for Machine Learning (ML) applications. [OSCAR](https://oscar.grycap.net) is an open-source serverless computing platform for data-processing applications, that can be used to deploy AI/ML models for inference.\n\nThis repository describes how to create Gradio apps for OSCAR services. \n\n## Prerequisites\n\nEach Gradio app needs to be adapted to the specific OSCAR service that will execute the pre-trained AI/ML model that is encapsulated as a Docker container image.\n\nFirst, deploy an OSCAR cluster and then, an OSCAR service: \n\n### Deploy an OSCAR cluster\n    To deploy in [localhost](https://docs.oscar.grycap.net/local-testing/) use the next command:\n\n    ``` sh\n    curl -sSL http://go.oscar.grycap.net | bash\n    ```\n\n    Also, OSCAR can be deployed with the [Infraastructure Manager (IM)](https://docs.oscar.grycap.net/deploy-im-dashboard/)\n\n### Deploy an OSCAR service\n    OSCAR services can be deployed with [OSCAR-CLI](https://docs.oscar.grycap.net/oscar-cli/) with the command `apply` or using the [UI](https://docs.oscar.grycap.net/usage/#deploying-services)\n\n    ``` sh\n    oscar-cli apply FDL_FILE\n    ```\n\n## Create your UI\n\nIf you are using an example that already exists, such as the ones in the `examples` folder, you can skip this part. Otherwise, first create a demo in localhost with [the components that Gradio provides](https://gradio.app/docs). Each service will need a different component depending on the inputs and outputs of the services. Take a look in the examples folder for assistance building your UI. To connect to the OSCAR services, use the [OSCAR Python library](https://pypi.org/project/oscar-python/).\n\n### Build Docker\n\nOnce the local demo works, changes need to be introduced to the Gradio app. The OSCAR cluster endpoint must be an environment variable with the value assigned at deployment time. Also, change the parameters of the [.launch()](https://gradio.app/docs/#launch) function by introducing `server_name` with the value `0.0.0.0`. The last change is the `server_port` variable as an environment variable `int(os.environ['port'])`.\n\n### Authentication\n\nBy default, Gradio apps are not protected with user credentials. Therefore, the `auth` parameter to the [.launch()](https://gradio.app/docs/#launch) method will create an authentication process.\n\nIn the `auth` parameter, assign a function that will be executed in the login process. This authentication can be made with the OSCAR cluster. For more information, check the code samples in the `examples` folder.\n\n## Try an example UI\n\nOnce the OSCAR cluster is up and running and the Docker image for the Gradio application is already built, verify that it works in `localhost` with the following command:\n\n```sh\ndocker run -it -e oscar_endpoint='{oscar_endpoint}' -e port=\"7000\" -p 7000:7000 ghcr.io/grycap/{image_name}\n```\n\n## Deployment  in Kubernetes\n\nOnce the containerised Gradio app works, it is time to deploy it in the Kubernetes cluster.\n\n### Apply the YAML file\n\nDeploy the YAML file to the Kubernetes cluster.\n\n``` kubectl apply -f deploy_gradio.yaml ```\n\n### Structure\n\nThis final section explains the minimum structure required for the YAML that is deployed in Kubernetes for the Gradio app. It contains three components. A Deployment is a component that creates pods. In case a pod fails, it will be replaced. A Service, is the component User interfaces with Gradio for the AI model inference in OSCAR services\n\nThen create a Deployment with a container from the Docker image and the required environment variables. It needs two environment variables to expose the service: the OSCAR endpoint and the port. Also, expose the container on a certain port.\n\n``` yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: {pod_name}\n  labels:\n    app: {pod_name}\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: {pod_name}\n  template:\n    metadata:\n        labels:\n          app: {pod_name}\n    spec:\n      containers:\n        - name: {pod_name}\n          image: ghcr.io/grycap/{image_name}\n          env:\n            - name: oscar_endpoint\n              value: {oscar_endpoint}\n            - name: port\n              value: \"30001\"\n          ports:\n            - name: web\n              containerPort: 30001\n              protocol: TCP\n```\n\nCreate a Service to have permanent access to the containers. This service will aim at the container port called `web`.\n\n``` yaml\napiVersion: v1\nkind: Service\nmetadata:\n  name: service-{pod_name}  \nspec:\n  selector:\n    app: {pod_name}\n  ports:\n    - protocol: TCP\n      port: 9000\n      name: service-port\n      targetPort: 30001\n  type: NodePort\n```\n\nFinally, create an Ingress resource to expose the service from outside of the cluster.\nIf it uses HTTPS protocol, add `nginx.ingress.kubernetes.io/backend-protocol: \"HTTPS\"` into the annotations of the ingress component.\n\n``` yaml\napiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n  name: ingress-{pod_name}\n  annotations:\n    kubernetes.io/ingress.class: \"nginx\"\n    cert-manager.io/cluster-issuer: \"letsencrypt-prod\"\nspec:\n  tls:\n  - hosts:\n    - {sub_domain}.{public_hostname}\n    secretName: {sub_domain}.{public_hostname}\n  rules:\n  - host: {sub_domain}.{public_hostname}\n    http:\n      paths:\n      - path: /\n        pathType: Prefix\n        backend:\n          service:\n            name: service-{pod_name}\n            port:\n              number: 9000\n```\n\n## Configure the DNS\n\nThe Docker with the Gradio app is probably deployed, but it cannot be accessed via the web. So, use a DNS service cloud like Amazon Route 53, Azure DNS or Google Cloud DNS to link the public IP of the front machine of the OSCAR cluster (the one that does not start with the prefix `10.`) with the subdomain you have been created in the DNS service.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrycap%2Foscar-gradio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrycap%2Foscar-gradio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrycap%2Foscar-gradio/lists"}