Skip to content

add sample python connector#320

Closed
abdullah-cognite wants to merge 3 commits intomainfrom
example-python-connector
Closed

add sample python connector#320
abdullah-cognite wants to merge 3 commits intomainfrom
example-python-connector

Conversation

@abdullah-cognite
Copy link
Collaborator

@abdullah-cognite abdullah-cognite commented Dec 19, 2025

Steps to test:

  • Prerequisite: make sure python is installed on your machine
  • Setup the config file (using config.example.yml)
  • Run the connector
  • Create a model (upload the simulate.py file from the scripts folder)
  • Create a routine
  • Run a simulation.

This is only a proof of concept. Allowing the connector to download and execute Python code (as a model) could pose a security risk. Ideally, the Python scripts should already reside on the VM, with parameters passed in via routines.

Model (simulate.py):
Screenshot 2025-12-19 at 07 18 59

Routine example:

Screenshot 2025-12-19 at 07 16 57

Succesful run:
Screenshot 2025-12-19 at 07 16 30

Run data:

Screenshot 2025-12-19 at 07 16 11

Routine JSON (Partial):

"configuration": {
    "schedule": {
      "enabled": false
    },
    "dataSampling": {
      "enabled": false
    },
    "logicalCheck": [],
    "steadyStateDetection": [],
    "inputs": [
      {
        "name": "inlet_temp",
        "referenceId": "inlet_temp",
        "value": 33,
        "valueType": "DOUBLE",
        "unit": {
          "name": "C",
          "quantity": "Temperature"
        }
      },
      {
        "name": "flow_rate",
        "referenceId": "flow_rate",
        "value": 1,
        "valueType": "DOUBLE",
        "unit": {
          "name": "bar",
          "quantity": "Pressure"
        }
      }
    ],
    "outputs": [
      {
        "name": "outlet_temp",
        "referenceId": "outlet_temp",
        "unit": {
          "name": "C",
          "quantity": "Temperature"
        },
        "valueType": "DOUBLE"
      }
    ]
  },
  "script": [
    {
      "order": 1,
      "steps": [
        {
          "order": 1,
          "stepType": "Set",
          "arguments": {
            "referenceId": "inlet_temp",
            "variable": "inlet_temp"
          }
        },
        {
          "order": 2,
          "description": "flow_rate",
          "stepType": "Set",
          "arguments": {
            "referenceId": "flow_rate",
            "variable": "flow_rate"
          }
        }
      ]
    },
    {
      "order": 2,
      "steps": [
        {
          "order": 1,
          "stepType": "Command",
          "arguments": {
            "script": "-"
          }
        }
      ]
    },
    {
      "order": 3,
      "steps": [
        {
          "order": 1,
          "stepType": "Get",
          "arguments": {
            "referenceId": "outlet_temp",
            "variable": "outlet_temp"
          }
        }
      ]
    }
  ]

@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.49%. Comparing base (5e5a028) to head (b4d070f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
- Coverage   74.59%   74.49%   -0.10%     
==========================================
  Files          38       38              
  Lines        4074     4074              
  Branches      487      487              
==========================================
- Hits         3039     3035       -4     
- Misses        852      856       +4     
  Partials      183      183              

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abdullah-cognite
Copy link
Collaborator Author

closing in favor of #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant