finding projects using a particular plugin

TheMLEngineer
TheMLEngineer Registered Posts: 25

Is there a quick way to find the projects using a particular plugin?

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,049 Neuron

    Navigate to the plugin page and select the Usages tab. Then click on Fetch Usages.

    Screenshot 2024-05-06 at 22.36.03.png

  • TheMLEngineer
    TheMLEngineer Registered Posts: 25

    Thank you. It works!!

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,049 Neuron
    edited July 17

    This notebook code is even better, it will run the check for all plugins and output a dataframe which you can then export to CSV. It may take some time to run depending on the number of plugins installed and the size of your install:

    from IPython.display import display, HTML
    display(HTML("<style>.container { width:100% !important; }</style>"))
    
    import dataiku
    import pandas as pd, numpy as np
    client = dataiku.api_client()
    
    plugins_list = client.list_plugins()
    filter_plugins_list = []
    
    df_plugin_usage = pd.DataFrame(columns=['plugin_id', 'plugin_name', 'plugin_author', 'plugin_version', 'plugin_license', 'plugin_code_env', 'element_kind', 'element_type', 'object_type', 'object_id'])
    
    for plugin in plugins_list:
        plugin_id = plugin['id']
        plugin_author = plugin['meta']['author']
        plugin_license = plugin['meta']['licenseInfo']
        plugin_version = plugin['version']
         
        if filter_plugins_list:
            if plugin_id not in filter_plugins_list:
                continue
        plugin_handle = client.get_plugin(plugin_id)
        plugin_settings = plugin_handle.get_settings().get_raw()
        plugin_name = plugin['meta']['label']
        plugin_code_env = plugin_settings.get('codeEnvName')
        plugin_usages = plugin_handle.list_usages(project_key=None).get_raw()
        for usages in plugin_usages['usages']:
            
            element_kind = usages['elementKind']
            element_type = usages['elementType']
            object_type = usages['objectType']
            project_key = usages['projectKey']
            object_id = usages['objectId']
        
            plugin_usage_record =  pd.DataFrame.from_dict({'plugin_id': [plugin_id], 'plugin_name': [plugin_name], 'plugin_code_env': [plugin_code_env], 'plugin_author': [plugin_author], 'plugin_version': [plugin_version], 'plugin_license': [plugin_license], 'project_key': [project_key], 'element_kind': [element_kind], 'element_type': [element_type], 'object_type': [object_type], 'object_id': [object_id]})
            df_plugin_usage = pd.concat([df_plugin_usage, plugin_usage_record], ignore_index=True)
        print(f'{plugin_id} - {plugin_name} - {plugin_code_env}')
    
    df_plugin_usage.sort_values(by=['plugin_name', 'project_key', 'element_kind', 'element_type', 'object_type', 'object_id'], inplace=True)
    
    import base64
    
    def create_download_link( df, title = "Download CSV file", filename = "plugin_usage.csv"):
        csv = df.to_csv()
        b64 = base64.b64encode(csv.encode())
        payload = b64.decode()
        html = '<a download="{filename}" href="data&colon;text/csv;base64,{payload}" target="_blank">{title}</a>'
        html = html.format(payload=payload,title=title,filename=filename)
        return HTML(html)
    
    create_download_link(df_plugin_usage)

Setup Info
    Tags
      Help me…