无法使用Looker API将Looker图表(视图)拉到Databricks中。

问题描述 投票:1回答:1

我的目标是访问我存储在Looker文件夹中的视图或图表,并将这些自动添加到power point幻灯片中。我所遵循的教程就是这个。https:/discourse.looker.comtgenerating-a-powerpoint-presentation-fromall-looks-in-a-space8191。.

我的问题是在点#生成PowerPoint(根据教程)。当我运行该命令时,失败的消息说:"当我打印'image_file'时,是空的('无')。

    103 chart_test
    Look failed 103: chart_test
    Failed to add image to slide

This corresponds to this piece of code where it fails:

try:
    image = looker_client.LookApi(client).run_look(**look_request)
    image_file = ''.join([str(look.id), '.png'])
    shutil.move(image, image_file)
except:
    print(f'Look failed {look.id}: {look.title}')
    image_file = None

当我打印'image_file'时,是空的('None'),虽然我有一个线图保存在这个文件夹2703,叫'chart_test'。

谁能帮助我?

python-3.x databricks looker
1个回答
1
投票

检查你的参数示例

look_request = {
            "look_id": 21, 
            "result_format": 'png', 
            "image_width": 960, 
            "image_height": 540
        } 

试着使用上一个SDK

import looker_sdk
import shutil 
from looker_sdk import models
sdk = looker_sdk.init40("looker.ini")
look_request = {
            "look_id": 21, 
            "result_format": 'html', 
            "image_width": 960, 
            "image_height": 540
        }

try:
    image1 = sdk.run_look(**look_request)
    image_file1 = '21.png'
    shutil.move(image1, image_file1)
except Exception as e:
    print(e)

你应该把looker.ini文件和你的py文件放在同一个文件夹里。

© www.soinside.com 2019 - 2024. All rights reserved.