Invoking library code from webapp isn't working

Sangavi_M
Sangavi_M Registered Posts: 10 ✭✭✭
edited July 16 in Using Dataiku

import dataiku
import pandas as pd, numpy as np
from dataiku import pandasutils as pdu
import time
    

def write_random(name: str):
    sample = dataiku.Dataset(name)
    sample.write_schema([{"name":"data", "type":"double"}])
    with sample.get_continuous_writer("source-id-string-dummy") as sample_writer:
        while True:
            val = np.random.rand()
            sample_writer.write_row_dict({'data': val})
            sample_writer.checkpoint(str(time.time()))
            time.sleep(1)


I was trying to run library code (streaming python type) from webapp on a button click but it was giving below error:

webapp lib error.png
even though im able to import and run the same thing just fine in a streaming python type recipie like this:

from continuous_python import write_random

write_random("sample")



could anyone help me with where I'm going wrong?

Answers

Setup Info
    Tags
      Help me…