Survey banner
The Dataiku Community is moving to a new home! New posts are now disabled and the community will shortly be in temporary read only mode: LEARN MORE

Macro run with api

Solved!
benbeckerfr
Level 2
Macro run with api

Hello, 

I am using Dataiku 9.0 version.

I develop a plugin to run a macro. This macro gets a folder from a managed_folder param that we indicate manually when we launch (with 'MANAGED_FOLDER' param in the Runnable.json). 

I am trying to launch it from the pythonapi, and do not know how to fill the param dict in DSSMacro.run(params={}) to precise the managed folder needed for the param. 

Does anyone had this issue for params in macro.run ? 

Thanks for your help.


Operating system used: linux

0 Kudos
1 Solution
ZachM
Dataiker

Hi @benbeckerfr,

The "params" kwarg is a dict of parameters that will be passed to the macro. For MANAGED_FOLDER parameters, the value should be set to the ID of the managed folder.

Here's an example:

run_id = my_macro.run(
    params={"my_folder": "9UQMRQ9O"}
)

 

Thanks,

Zach

View solution in original post

5 Replies
ZachM
Dataiker

Hi @benbeckerfr,

The "params" kwarg is a dict of parameters that will be passed to the macro. For MANAGED_FOLDER parameters, the value should be set to the ID of the managed folder.

Here's an example:

run_id = my_macro.run(
    params={"my_folder": "9UQMRQ9O"}
)

 

Thanks,

Zach

Raj7974
Level 2

an you please guide how to pass value to select parameters of macro to run macro using python api

Lable of parameter is Project Key

Name is prj_key

0 Kudos
ZachM
Dataiker

Hi @Raj7974,

To pass a SELECT parameter, you would set the parameter to the value of the choice.

For example, with the following SELECT parameter:

{
    "name": "prj_key",
    "label": "Project Key",
    "type": "SELECT",
    "selectChoices": [
        {
            "value": "foo",
            "label": "Label for foo"
        },
        {
            "value": "bar",
            "label": "Label for bar"
        }
    ]
}

You would run it by setting the value to "foo" or "bar":

run_id = my_macro.run(
    params={"prj_key": "foo"}
)

 

0 Kudos
Raj7974
Level 2

Can you please share steps to create plugin so that it will be visible in action of flows.

I know how to create macros but I want it in Action just like we have options of duplicate, export and delete

0 Kudos
ZachM
Dataiker

You can configure a macro to appear in the action menu by adding a macro role. Documentation is available here: https://doc.dataiku.com/dss/latest/plugins/reference/macros.html#macro-roles

For example, the Excel sheet importer plugin adds a macro with the MANAGED_FOLDER role, which is visible under "Other actions" as shown below:

5907171F-ABD1-47D1-90C6-773C4A662485_1_201_a.jpeg

 

0 Kudos