Community Conundrum 28: News Engagement is live! Read More

Creating project from bundel on automation node using python API

Level 1
Creating project from bundel on automation node using python API

Using the python API we have created a bundle on the Design node. We would like to use this bundle to create a new project on the Automation node. We get an 405 error, which says that the "GET" method is not supported for URL. 

The code which runs on the dataiku Design node:

import dataiku

import dataikuapi

 

client = dataiku.api_client()

project_key = "AAA_BBB_CCC"

project = client.get_project(project_key=project_key) 

bundle_id = "test_v1"

project.export_bundle (bundle_id)

If I use project.exported_bundles() I can confirm that the bundle was indeed exported. And when I examine the directory test_v1.zip is created.

-------------------------------------------------------------------------

Here I connect to the automation node and try to create a project from test_v1.zip

host = "url_automation:port"

api_key = "xxxxxxxxxxxxxxxxxxxxxxx"

auto_client = dataikuapi.DSSClient(host, api_key)

project = auto_client.get_project(project_key = project_key) 

auto_client.create_project_from_bundle_archive("test_v1.zip")

Now i get the 405 error, I tried to use streams instead of archive but i still recieved the 405 error described above. 

 

 

0 Kudos
1 Reply
Dataiker
Dataiker

Hi,

I'm not sure why you are getting 405 error but here is the code I'm using to create 'v1' bundle on Design and import to Automation. This code will also create project (required when pushing your first version) and activate the bundle

client_des = dataikuapi.DSSClient(hostname_design, design_admin_api_key)
client_aut = dataikuapi.DSSClient(hostname_auto, auto_api_key)
proj_key = 'DKU_TUTORIAL_PYTHON'
project_des = client_des.get_project(proj_key)
project_aut = client_aut.get_project(proj_key)
bundle = 'v1'
project_des.export_bundle(bundle)
aut_projects = client_aut.list_project_keys()
fp = project_des.get_exported_bundle_archive_stream(bundle)
if not proj_key in aut_projects:
    client_aut.create_project_from_bundle_archive(fp.content)
else:
    project_aut.import_bundle_from_stream(fp.content)
project_aut.activate_bundle(bundle)

If you still get an error please provide full code and full error output

0 Kudos
A banner prompting to get Dataiku DSS