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

parse argument int on str #544

Open
galdinoTH opened this issue Jul 7, 2024 · 2 comments
Open

parse argument int on str #544

galdinoTH opened this issue Jul 7, 2024 · 2 comments
Assignees

Comments

@galdinoTH
Copy link

Running this query
{'reportQuery': {'dimensions': ['DATE', 'HOUR', 'AD_UNIT_ID', 'AD_UNIT_NAME'], 'adUnitView': 'HIERARCHICAL', 'columns': ['AD_EXCHANGE_LINE_ITEM_LEVEL_IMPRESSIONS', 'AD_EXCHANGE_LINE_ITEM_LEVEL_CLICKS', 'TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE'], 'dateRangeType': 'LAST_MONTH'}}

I faced with this traceback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/googleads/common.py", line 982, in MakeSoapRequest
return soap_service_method(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/zeep/proxy.py", line 46, in call
return self._proxy._binding.send(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 135, in send
return self.process_reply(client, operation_obj, response)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 229, in process_reply
return self.process_error(doc, operation)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 317, in process_error
raise Fault(
zeep.exceptions.Fault: Unknown fault occured
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/apscheduler/executors/base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "/Users/thalysongaldino/Dev/roi-manager-project/batch_schedule_processing./scheduler/jobs.py", line 214, in get_data_ad_manager
run_report = run_report_and_wait(report_service, report_job)
File "/Users/thalysongaldino/Dev/roi-manager-project/batch_schedule_processing./scheduler/jobs.py", line 224, in run_report_and_wait
report_job_id = report_service.WaitForReport(report_job)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/googleads/ad_manager.py", line 896, in WaitForReport
report_job_id = service.runReportJob(report_job)['id']
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/googleads/common.py", line 987, in MakeSoapRequest
underlying_exception = e.detail.find(
TypeError: argument should be integer or bytes-like object, not 'str'

anyone can i help my?

@msaniscalchi msaniscalchi self-assigned this Jul 11, 2024
@msaniscalchi
Copy link
Contributor

I attempted to reproduce with an identical query, but the operation completes successfully. It's possible that something you're receiving is triggering this error, or there is some sort of environment/implementation issue.

What version of the library / Python are you using? I might be able to learn something if there's a snippet of code you can share that reproduces the issue for you consistently.

@galdinoTH
Copy link
Author

thank your for your information
as you can see below that code already use to specific implementation
def get_data_ad_manager():
users = print_all_active_users()

for user in users:
    keys = load_keyfile_in_memory(user.refresh_token, user.network_code)
    client = ad_manager.AdManagerClient.LoadFromString(keys)
    report_service = client.GetDataDownloader(version=_API_AD_VERSION)

    # Calculate the start and end times for the last hour
    end_time = datetime.utcnow()
    start_time = end_time - timedelta(hours=_INTERVAL_AD_MANAGER_HOUR_QUERY)

    # Create report query that i send before
    report_job_query= {'reportQuery': {'dimensions': ['DATE', 'HOUR', 'AD_UNIT_ID', 'AD_UNIT_NAME'], 'adUnitView': 'HIERARCHICAL', 'columns': ['AD_EXCHANGE_LINE_ITEM_LEVEL_IMPRESSIONS', 'AD_EXCHANGE_LINE_ITEM_LEVEL_CLICKS', 'TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE'], 'dateRangeType': 'LAST_MONTH'}}
    report_job = report_job_query

    run_report = run_report_and_wait(report_service, report_job)
    print(f"Report file path: {run_report}")

    report_file_path = run_report_and_download_file(report_service, run_report)
    print(f"Report file path: {report_file_path}")

    read_report_with_pandas(user.id, run_report, report_file_path)

def run_report_and_wait(report_service, report_job):
try:
report_job_id = report_service.WaitForReport(report_job)
print("Relatório iniciado com o ID:", report_job_id)
return report_job_id
except errors.AdManagerReportError as e:
print(f'Failed to generate report. Error was: {e}')
return None

When running report_job_id=report_service.WaitForReport(report_job) I get stack trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants