Sign inSign up

cognite/function-action

By cognite

•Updated almost 2 years ago

Image
0

100K+

cognite/function-action repository overview

⁠Deploy Cognite Function action

This container deploys a Python function to Cognite Functions, optionally with schedule(s).

In Azure Pipelines sample repo: https://github.com/cognitedata/functions-deploy-azure-pipelines⁠

⁠Inputs

⁠Function metadata

Set as environment variables when executing python /app/index.py

⁠Required
  1. INPUT_FUNCTION_EXTERNAL_ID: What we will use as external_id for the function. If it is not unique within your project, the existing function will be overwritten!
  2. INPUT_FUNCTION_FOLDER: Parent folder for the function's code. Everything within this folder will be uploaded (so if you need your special CSV-file; don't worry, it will automatically be included!)
  3. INPUT_CDF_PROJECT: The name of your CDF project.
  4. INPUT_CDF_CLUSTER: The cluster your customer's CDF project lives in, like westeurope-1 or greenfield.
  5. INPUT_DEPLOYMENT_CLIENT_SECRET: Client secret, only to be used for DEPLOYMENT of the function.
  6. INPUT_DEPLOYMENT_CLIENT_ID: Client ID, only to be used for DEPLOYMENT of the function.
  7. INPUT_DEPLOYMENT_TENANT_ID: Tenant ID, only to be used for DEPLOYMENT of the function.
⁠Required if attaching schedules
  1. INPUT_SCHEDULE_FILE: File location inside function_folder containing a list of schedules to be attached to your function. If this file exists, then schedules_client_secret, schedules_client_id and schedules_tenant_id will be required. Note: Schedule file will be ignored with a warning if it is pointing to a non-existing file. More details in section below.
  2. INPUT_SCHEDULES_CLIENT_SECRET: Client secret to be used at RUNTIME for the function, but ONLY for its scheduled runs! Note: Calling the function normally, still uses the caller's credentials!.
  3. INPUT_SCHEDULES_CLIENT_ID: Client ID to be used at RUNTIME for the function, but ONLY for its scheduled runs!
  4. INPUT_SCHEDULES_TENANT_ID: Tenant ID to be used at RUNTIME for the function, but ONLY for its scheduled runs!
⁠Optional

All optional parameters that has default values, can be found in src/defaults.py, i.e. they are not defined in action.yaml because of the typical multi-deploy-pattern used with this action.

  1. INPUT_REMOVE_ONLY: Short-cut: Deletes function along with all attached schedules. Ignores most other parameters!
  2. INPUT_COMMON_FOLDER: The path to the folder containing code that is shared between functions. See section below for more details.
  3. INPUT_FUNCTION_FILE: The name of the file with your main function. Will default to handler.py if not given.
  4. INPUT_FUNCTION_SECRETS: The name of a Github secret that holds the base64-encoded JSON dictionary with secrets (see "secrets section").
  5. INPUT_FUNCTION_DEPLOY_TIMEOUT: The timeout limit (in seconds) for the function deployment. Once the timeout is reached, the deployment is canceled (an attempt to delete the function will be made).
  6. INPUT_DATA_SET_ID: Data set ID to use for the file uploaded to CDF (the function-associated file: zipped code folder). Requires two additional DEPLOYMENT capabilities: 'dataset:READ' and 'files:WRITE' scoped to either the dataset you are going to use, or 'all'. Note: If your data set is WRITE PROTECTED, you also need to add the capability 'dataset:OWNER' for it. Read more about data sets in the official documentation: Data sets⁠
  7. INPUT_POST_DEPLOY_CLEANUP: Delete the code file object from CDF Files after successful Function deployment. Defaults to true.
  8. INPUT_DESCRIPTION: Additional field to describe the function.
  9. INPUT_OWNER: Additional field to describe the function owner.
  10. INPUT_CPU: Set fractional number of CPU cores per function. Ignored for functions running on Azure!. See defaults and allowed values in the API documentation⁠.
  11. INPUT_MEMORY: Set memory per function measured in GB. Ignored for functions running on Azure!. See defaults and allowed values in the API documentation⁠.
⁠Schedule file format [.yaml]
- name: Daily schedule
  cron: "0 0 * * *"
  data:
    lovely-parameter: True
    something-else: 42
- name: Hourly schedule
  cron: "0 * * * *"
  data:
    lovely-parameter: False
    something-else: 777
- name: Hourly schedule  # Same name as another schedule (allowed), but with no `data` (also allowed).
  cron: "0 * * * *"

Tag summary

Content type

Image

Digest

sha256:4205789eb…

Size

384.6 MB

Last updated

almost 2 years ago

docker pull cognite/function-action:v1-github