Coder Social home page Coder Social logo

zhenghongpeng / air-model-template-repo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cognitedata/air-model-template-repo

0.0 1.0 0.0 134 KB

The purpose of this repository is to provide a way for customers to interact with AIR and deploy models to CDF.

License: Apache License 2.0

Shell 81.77% Python 18.23%

air-model-template-repo's Introduction

AIR Function Template

Before proceeding make sure all necessary onboarding steps are done.

Installation steps

  1. To use this repo as a template create a new repo and use air-template under templates.
  2. Install poetry in your terminal of choice.
  3. poetry install: Run this cmd in terminal.
  4. poetry run pre-commit install: This installs the required pre-commit hooks.

Setting up Github secrets for API keys

Please Note : API keys are deprecated,please use OIDC authentication going forward.

  1. This repo makes use of GitHub Actions to perform deployment and testing of your model.

  2. The air-demo-repo template requires the following secrets to be defined in GitHub (Settings >> Secrets):

    a) PROJECT_NAME_API_KEY: This is your api key for the project in question . For example an API key for eureka tad dev would be defned as EUREKA_TAD_DEV_API_KEY.

Please make sure that your api key has the correct permissions required to use Cognite Functions and AIR.

Setting up Github secrets for OIDC projects

  1. This repo makes use of GitHub Actions to perform deployment and testing of your model.

  2. The air-model-template-repo requires the following secrets to be defined in GitHub (Settings >> Secrets):

    a) PROJECT_NAME_SECRET: This is the secret value for a given OIDC authentication client.

Please ensure that this secret name matches what is defined in the reconfig.yaml file.

Creating a Model

(Find all documentation here: air-documentation)

  1. Create a new development branch with git checkout -b your_branch_name.

  2. Any function in this repo needs to have it's own folder in the functions folder. In order to get started feel free to rename and edit the existing templatefunction.

  3. Edit the config.yaml. This file is handling the interaction with the AIR Infrastructure and Front End. Read more about it here.

  4. When using AIR, it is encouraged to use the AIR client to get all the benefits of retrieving information about schedules, writing versioned, Events, notifications to the end user, and visualize calculated Time Series in the Front End.

  5. Add all required libraries for your function to the requirements.txt file. Please make sure to add the air-sdk library to the requirements for every project. Additionally, install all packages to poetry as well since those are needed for unit and integration tests.

  6. Navigate to the repoconfig.yaml file in the root folder and under the project properties tab make sure to map the project to its corresponding authentication. Under the ProjectFunctionMap write the name of the function that needs to be deployed as well as the project you wish to deploy to.

  7. Testing can be done by making use of a test handler under the test folder in your function_name folder.

  8. If an existing function should not be deployed, the folder name needs to be added to the .ignore_models file.

  9. Once the function is ready, add, commit and push it to open a pull request.

  10. In order to deploy a function to cognite functions squash and merge the PR that was created in the above step.

Troubleshooting

  1. If an error pops up in github actions which states that there is a bad token. This means that appropriate privileges have not been given to the api key.

Contact

If you wish to contribute or run into any issues please contact us directly:

  1. AIR-TEAM : [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.