I am trying to do some clean up and want to loop thru a list of notebooks in our Repo to look for a certain function. Lets call it do_stuff(). I try using the API and it is not working.
So far:
def search_function_in_notebook(notebook_path, function_name):
url = f'{domain}/api/2.0/workspace/export'
params = {'path': notebook_path, 'format': 'SOURCE'} # Ensure format is 'SOURCE'
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
source_code = response.text
# Check if the function name is in the source code
if function_name in source_code:
return True
return False
else:
# Handle errors or unsuccessful API calls
return False
This did not work as the response text is a bunch of random text where it is impossible to search for any python. Any help is appreciated