ModalCLI ​Modal​C​L​I

yaml
type: "io.kestra.plugin.modal.cli.modalcli"
yaml
id: modal_hello_world
namespace: company.team
tasks:
  - id: hello
    type: io.kestra.plugin.modal.cli.ModalCLI
    env:
      MODAL_TOKEN_ID: "your_modal_token_id"
      MODAL_TOKEN_SECRET: "your_modal_token_secret"
    commands:
      - modal run hello.py
    inputFiles:
    hello.py: |
      import modal

      app = modal.App("hello-world")

      @app.function()
      def hello():
          print("hello from modal")
          return "Success!"

yaml
id: env_vars_modal
namespace: company.team
inputs:
  - id: run_modal
    displayName: Whether to run the Modal task
    type: BOOLEAN
    defaults: true
  - id: cpu
    type: SELECT
    displayName: CPU request
    description: The number of CPU cores to allocate to the container
    defaults: "0.25"
    values: ["0.25", "0.5", "0.75", "1.0", "1.5", "2.0", "4.0", "8.0", "16.0", "32.0"]
    dependsOn:
      inputs:
        - run_modal
      condition: "{{ inputs.run_modal equals true }}"

  - id: memory
    type: SELECT
    displayName: Memory request
    description: Amount of memory in MiB to allocate to the container
    defaults: "512"
    values: ["512", "1024", "2048", "4096", "8192", "16384", "32768"]
    dependsOn:
      inputs:
        - run_modal
      condition: "{{ inputs.run_modal }}"
tasks:
  - id: set_compute_resources
    type: io.kestra.plugin.modal.cli.ModalCLI
    env:
      MODAL_TOKEN_ID: "{{ secret('MODAL_TOKEN_ID') }}"
      MODAL_TOKEN_SECRET: "{{ secret('MODAL_TOKEN_SECRET') }}"
      CPU: "{{ inputs.cpu }}"
      MEMORY: "{{ inputs.memory }}"
    commands:
      - modal run script.py
    inputFiles:
      script.py: |
        import os
        import modal

        app = modal.App(
            "env-vars",
            secrets=[modal.Secret.from_local_environ(env_keys=["CPU", "MEMORY"])],
        )


        @app.function(cpu=float(os.getenv("CPU")), memory=int(os.getenv("MEMORY")))
        def generate_data():
            cpu = os.getenv("CPU")
            memory = os.getenv("MEMORY")
            resources = dict(cpu=cpu, memory=memory)
            print(f"Running the function with CPU={cpu} and MEMORY={memory}")
            return resources


        @app.local_entrypoint()
        def main():
            output = generate_data.remote()
            print(f"hello from main function - output is: {output}")

yaml
id: modal_git
namespace: company.team

tasks:
  - id: repository
    type: io.kestra.plugin.core.flow.WorkingDirectory
    tasks:
      - id: clone
        type: io.kestra.plugin.git.Clone
        branch: main
        url: https://github.com/kestra-io/scripts

      - id: modal_cli
        type: io.kestra.plugin.modal.cli.ModalCLI
        commands:
          - modal run modal/getting_started.py
        env:
          MODAL_TOKEN_ID: "{{ secret('MODAL_TOKEN_ID') }}"
          MODAL_TOKEN_SECRET: "{{ secret('MODAL_TOKEN_SECRET') }}"

yaml
id: modal
namespace: company.team

tasks:
  - id: modal_cli
    type: io.kestra.plugin.modal.cli.ModalCLI
    namespaceFiles:
      enabled: true
    commands:
      - modal run gpu.py
    env:
      MODAL_TOKEN_ID: "{{ secret('MODAL_TOKEN_ID') }}"
      MODAL_TOKEN_SECRET: "{{ secret('MODAL_TOKEN_SECRET') }}"
Properties
SubType string
SubType string
Default ghcr.io/kestra-io/modal
SubType string
SubType string
Default 0
SubType string
Default busybox
Default true
SubType string
Default false
Default OVERWRITE
Possible Values
OVERWRITEFAILWARNIGNORE
SubType string
SubType string
Default ["{{flow.namespace}}"]
Default true
Default { "image": "busybox" }
Default default
Default ALWAYS
Possible Values
IF_NOT_PRESENTALWAYSNEVER
Default true
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default PT1H
Format duration
Default PT10M
Format duration
Default PT5S
Format duration
Default true
Default true
Default false
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT1H
Format duration
SubType integer
Default PT5S
Format duration
Default true
Default true
SubType string
Default ["https://www.googleapis.com/auth/cloud-platform"]
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default PT1H
Format duration
Possible Values
ACTION_UNSPECIFIEDRETRY_TASKFAIL_TASKUNRECOGNIZED
Default v1
Default RSA
Default https://kubernetes.default.svc
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default true
SubType string
Default e2-medium
Default 2
Minimum >= 0
Maximum <= 10
Default true
SubType string
Default ["https://www.googleapis.com/auth/cloud-platform"]
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default PT1H
Format duration
Min length 1
SubType
SubType string
SubType string
Default IF_NOT_PRESENT
Possible Values
IF_NOT_PRESENTALWAYSNEVER
SubType string
Default true
SubType
SubType string
Default [ "" ]
SubType string
Default VOLUME
Possible Values
MOUNTVOLUME
Default PT0S
Format duration
SubType string
Default IF_NOT_PRESENT
Possible Values
IF_NOT_PRESENTALWAYSNEVER
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
SubType string
Default true
SubType array
SubType string
SubType string
Default PT5S
Format duration
Default true
Default { "request": { "memory": "2048", "cpu": "1" } }
Default true
Default PT15M
Format duration
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT1H
Format duration