Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account object has no attribute trace #219

Open
shaun10 opened this issue Aug 12, 2019 · 9 comments
Open

Account object has no attribute trace #219

shaun10 opened this issue Aug 12, 2019 · 9 comments
Assignees
Labels

Comments

@shaun10
Copy link
Contributor

shaun10 commented Aug 12, 2019

  File "/opt/conda/lib/python2.7/site-packages/twitter_ads/account.py", line 55, in all
    return Cursor(klass, request, init_with=[client])
  File "/opt/conda/lib/python2.7/site-packages/twitter_ads/cursor.py", line 29, in __init__
    self.__from_response(request.perform())
  File "/opt/conda/lib/python2.7/site-packages/twitter_ads/http.py", line 65, in perform
    if self.client.trace:
AttributeError: 'Account' object has no attribute 'trace'

Is this normal? There is an all method but getting a trace error.

@smaeda-ks
Copy link
Contributor

@shaun10 Please provide your code snippet.

@shaun10
Copy link
Contributor Author

shaun10 commented Aug 13, 2019

entities_df = json_normalize([item.to_params() for item in Account.all(account_object)], sep='_')
Account object is an account object iterated over from the below.
accounts = client.accounts()

@smaeda-ks
Copy link
Contributor

@shaun10 That seems wrong.
When you call accounts = client.accounts() without any arguments, that means you're silently calling Account.all() anyway, so you don't have to do it again.
https://github.com/twitterdev/twitter-python-ads-sdk/blob/master/twitter_ads/client.py#L89

@shaun10
Copy link
Contributor Author

shaun10 commented Aug 15, 2019

So doing it again is restricted for the Account? I am trying to use the resource.py to_params to get all of the account information and attributes.

@smaeda-ks
Copy link
Contributor

@shaun10 Why not just do something like:

account_object = client.accounts()
entities_df = json_normalize([item.to_params() for item in account_object], sep='_')

@smaeda-ks smaeda-ks self-assigned this Aug 20, 2019
@smaeda-ks
Copy link
Contributor

@shaun10 Let me know if you still have a question for this, or I'll close this later.

@shaun10
Copy link
Contributor Author

shaun10 commented Aug 20, 2019

@smaeda-ks yeah I can do it with the suggested approach but I have to add a conditional statement to the method because I cannot call a generic Object.all() because for Account object all is already called and I cannot re-call the all method.

@smaeda-ks
Copy link
Contributor

@shaun10 Sorry, but I don't get your point. Could you elaborate what's your goal here and what's the problem you're trying to solve?

Since with that approach, entities_df has a list which has all the necessary information you need and I'm wondering why you want to call .all() again.

@shaun10
Copy link
Contributor Author

shaun10 commented Aug 21, 2019

So high level I have a method that is called and takes an entity object and then stores all the returned entities in a data frame to produce lookup data for the account. I have many accounts so I call all on every account for a given entity type then store the results in a table. I take the entity object into the method then call .all to get all of the entities back and store them. I have a predefined column list I use to control what columns I store in the data frame. I then take that and save it to a file and store it in a table. The all is pretty much everything here. I just didn't understand why all could be called on PromotedTweet, MediaLibrary, FundingInstrument etc but not on the Account.

I created lookup tables already for most of these data types but it looks like I can't do it for the Account?

@xdevplatform xdevplatform deleted a comment from shaun10 Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants