Forum Discussion

A_monged's avatar
A_monged
Frequent Visitor
1 year ago
Solved

How to retrieve current notebook name

How to retrieve the current notebook name  I don't want to hardcode it
  • spencer_sa's avatar
    1 year ago

    You should be able to get a stack of useful info from the notebookutils.runtime.context structure.

    For example, executing the below:

    print(notebookutils.runtime.context['currentNotebookName'])

    returns to following imaginatively titled name;

    MyAwesomeNotebook

     
    The full list of things you can return is;

    'currentNotebookName', 'currentWorkspaceName', 'defaultLakehouseName', 'defaultLakehouseId', 'parentRunId', 'isReferenceRun', 'defaultLakehouseWorkspaceId', 'hcReplId', 'activityId', 'defaultLakehouseWorkspaceName', 'currentWorkspaceId', 'referenceTreePath', 'clusterId', 'poolName', 'environmentId', 'currentNotebookId', 'userId', 'environmentWorkspaceId', 'userName', 'currentRunId', 'isForPipeline', 'rootRunId'

     

    If this helps at all, please consider Accepting as a Solution so that other users may find it more easily.