Create new workbooks with code

invalidargument
New Contributor III

Is is possible to create new notebooks from a notevbook in databricks?

 

I have tried this code. But all of them are generic files, not notebooks.

notebook_str = """# Databricks notebook source

import pyspark.sql.functions as F
import numpy as np

# COMMAND ----------

# A test notebook
np.__version__
"""
with open("./notebook.ipynb","w") as f:
    f.write(notebook_str)

with open("./notebook.py","w") as f:
    f.write(notebook_str)

with open("./notebook","w") as f:
    f.write(notebook_str)

invalidargument
New Contributor III

Unfortunaly %run does not help me since I can't %run a .py file. I still need my code in notebooks.

I am transpiling propriatary code to python using jinja templates. I would like to have the output as notebooks since those are most convenient to edit in databricks.

Perhaps calling the workspace API is a possible way forward then? Can i call this from a databrick notebook?
Import a workspace object | Workspace API | REST API reference | Databricks on AWS