chezou / tdworkflow

Unofficial Treasure Workflow Client
Apache License 2.0
7 stars 5 forks source link

Support status field in Attempts #8

Closed toru-takahashi closed 4 years ago

toru-takahashi commented 4 years ago

I notice that attempts PUT API returns status field now. I'm not sure if this is from the beginning or not. But, right now, using start_attempt shows the following behavior.

The following work

import tdworkflow
client = tdworkflow.client.Client(site='us', apikey='1/xxxx')

# https://console.treasuredata.com/app/workflows/157647/info
project = client.project(40357)
workflows = client.project_workflows(project)
client.start_attempt(workflows[0])

But the following code got an error.

import tdworkflow
client = tdworkflow.client.Client(site='us', apikey='1/xxxx')

client = tdworkflow.client.Client(site='us', apikey='1/1495214ab39b6beccf8fd57163910ec0b4e41715')
# https://console.treasuredata.com/app/workflows/157647/info
project = client.project(40357)
workflows = client.project_workflows(project)
attempt = client.start_attempt(workflows[0])
Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
 > File "/Users/toru/.pyenv/versions/3.7.4/lib/python3.7/site-packages/tdworkflow/client.py", line 484, in start_attempt
 >   return Attempt(**r)
>TypeError: __init__() got an unexpected keyword argument 'status'

This is because Attempt class doesn't have status field. https://github.com/chezou/tdworkflow/blob/master/tdworkflow/attempt.py#L11-L25

toru-takahashi commented 4 years ago

I have a fix, will send PR soon.

chezou commented 4 years ago

Fixed by #9