confluent-kafka python library is not working with ubutu14 and python3 - apache-kafka

I am using "confluent-kafka==1.0.1". It works fine when I am using py3 and ubuntu18, but fails with py3 and ubuntu14. I get the following error.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/metrics_agent/kafka_writer.py", line 147, in enqueue_for_topic
producer.produce(topic_name, msg, partition=_get_partition(producer, topic_name))
File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serializing_producer.py", line 168, in produce
raise KeySerializationError(se)
confluent_kafka.error.KeySerializationError:
KafkaError{code=_KEY_SERIALIZATION,val=-162,str="'bytes' object has no attribute 'encode'"}
Exception KafkaError{code=_KEY_SERIALIZATION,val=-162,str="'bytes' object has no attribute
'encode'"}
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serializing_producer.py", line 166, in produce
key = self._key_serializer(key, ctx)
File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serialization/__init__.py", line 369, in __call__
return obj.encode(self.codec)
AttributeError: 'bytes' object has no attribute 'encode'

Related

Stackstorm - Jira pack actions via UI/Rest Api - Failed with 'oauth' method

I am trying to create a issue with Jira pack and with I am trying to oauth with token i am getting the following error:
{
"stdout": "",
"stderr": "Traceback (most recent call last):
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/utils.py\", line 132, in get_action_class_instance
action_instance = action_cls(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'action_service'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py\", line 395, in <module>
obj.run()
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py\", line 213, in run
action = self._get_action_instance()
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py\", line 290, in _get_action_instance
action_instance = get_action_class_instance(
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/utils.py\", line 143, in get_action_class_instance
action_instance = action_cls(**kwargs)
File \"/opt/stackstorm/packs/jira/actions/lib/base.py\", line 17, in __init__
self._client = self._get_client()
File \"/opt/stackstorm/packs/jira/actions/lib/base.py\", line 27, in _get_client
rsa_cert_file = config['rsa_cert_file']
KeyError: 'rsa_cert_file'
3:01
Tried to create an issue via StackStorm with the UI/RestApi.
Failed with oauth method and success with basic method.
Can someone suggest how can i resolve this?
Thanks,
Or Hasson

google.api_core.exceptions.ServiceUnavailable: 503 Deadline Exceeded

google.api_core.exceptions.ServiceUnavailable: 503 Deadline Exceeded
using python 3.7 ,google-cloud-pubsub ==1.1.0 publishing data on topic. In my local machine it's working perfectly fine and able to publish data on that topic and also able to pull data from that topic through subscriber.
but don't understand it's not working when i deploy the code on server and it's failing with INLINE ERROR however when i explicitly call the publisher method on server it's publishing fine over server box also.code which is failing at below line while publishing:
future = publisher.publish(topic_path, data=data)
**ERROR:2020-02-20 14:24:42,714 ERROR Failed to publish 1 messages.**
Trackback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 826, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Deadline Exceeded"
debug_error_string = "{"created":"#1582208682.711481693","description":"Deadline Exceeded","file":"src/core/ext/filters/deadline/deadline_filter.cc","file_line":69,"grpc_status":14}"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/usr/local/lib/python3.7/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.ServiceUnavailable: 503 Deadline Exceeded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/cloud/pubsub_v1/publisher/_batch/thread.py", line 219, in _commit
response = self._client.api.publish(self._topic, self._messages)
File "/usr/local/lib/python3.7/site-packages/google/cloud/pubsub_v1/gapic/publisher_client.py", line 498, in publish
request, retry=retry, timeout=timeout, metadata=metadata
File "/usr/local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 143, in call
return wrapped_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 286, in retry_wrapped_func
on_error=on_error,
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 206, in retry_target
last_exc,
File "", line 3, in raise_from
google.api_core.exceptions.RetryError: Deadline of 60.0s exceeded while calling functools.partial(.error_remapped_callable at 0x7f67d064e950>
You should try to chunk your data in reasonable sized chunks (max_messages) and don't forget to add a done callback.
# Loop over json containing records/rows
for idx, row in enumerate(rows_json):
publish_json(row, idx, rowmax=len(rows_json), topic_name)
# Publish messages asynchronous
def publish_json(msg, rowcount, rowmax, topic_project_id, topic_name):
batch_settings = pubsub_v1.types.BatchSettings(max_messages=100)
publisher = pubsub_v1.PublisherClient(batch_settings)
topic_path = publisher.topic_path(topic_project_id, topic_name)
future = publisher.publish(
topic_path, bytes(json.dumps(msg).encode('utf-8')))
future.add_done_callback(
lambda x: logging.info(
'Published msg with ID {} ({}/{} rows).'.format(
future.result(), rowcount, rowmax))
)

supress_callback_exceptions = True no loger works

In an older version of Dash, I used to need to be able to say,
supress_callback_exceptions = True
Since I upgraded to the new version of Dash, now I get an error on that line:
Traceback (most recent call last):
File "dash-yahoo_options.py", line 2109, in <module>
app.config.supress_callback_exceptions = True
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 81, in __setattr__
self[key] = value
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 106, in __setitem__
raise AttributeError(final_msg, key)
AttributeError: ('Invalid config key. Some settings are only available via the Dash constructor', 'supress_callback_exceptions')
(dash_apps_36) idf#ubvm:~/Downloads$ vi dash-yahoo_options.py
(dash_apps_36) idf#ubvm:~/Downloads$ python dash-yahoo_options.py
Traceback (most recent call last):
File "dash-yahoo_options.py", line 2109, in <module>
app.config.supress_callback_exceptions = True
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 81, in __setattr__
self[key] = value
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 106, in __setitem__
raise AttributeError(final_msg, key)
AttributeError: ('Invalid config key. Some settings are only available via the Dash constructor', 'supress_callback_exceptions')
In case you missed it in the Dash change log, this misspelled fallback was removed in 1.0.0.
The configuration attribute should still supported (as at 1.6.0), you just need to use the right name.
app.config.suppress_callback_exceptions = True

PermissionDenied: 403 error when trying to run async Google Cloud Speech async transcribe

I'm getting the following error when trying to run an async transcription request on a .flac file hosted on google cloud.
$ python3 transcribe_async.py gs://[file].flac
Traceback (most recent call last):
File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 54, in error_remapped_callable
return callable_(*args, **kwargs)
File "[]/anaconda3/lib/python3.6/site-packages/grpc/_channel.py", line 514, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "[]/anaconda3/lib/python3.6/site-packages/grpc/_channel.py", line 448, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "The caller does not have permission"
debug_error_string = "{"created":"#1533912393.258761000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1095,"grpc_message":"The caller does not have permission","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "transcribe_async.py", line 105, in <module>
transcribe_gcs(args.path)
File "transcribe_async.py", line 83, in transcribe_gcs
operation = client.long_running_recognize(config, audio)
File "[]/anaconda3/lib/python3.6/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 284, in long_running_recognize
request, retry=retry, timeout=timeout, metadata=metadata)
File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/gapic_v1/method.py", line 139, in __call__
return wrapped_func(*args, **kwargs)
File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/retry.py", line 260, in retry_wrapped_func
on_error=on_error,
File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/retry.py", line 177, in retry_target
return target()
File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/timeout.py", line 206, in func_with_timeout
return func(*args, **kwargs)
File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 56, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission
I've added an export statement to my .zshrc file that points to the service account json, I've added myself, the service account email and the project owner and editor as owners of the cloud bucket through the browser, and I ran gcloud auth activate-service-account --key-file="[].json", but nothing helps. What have I forgotten? Any help much appreciated.
You need to make your file publicly readable. Once you set the permissions to allUsers, you will be able to use your file in your request.

Jupyter notebook and anaconda

I installed Jupyter in Ubuntu, and I use Anaconda. When I try to open a new empty ipython notebook, I get the error 'NameError: global name 'datetime' is not defined'. I transcribe below the complete error message:
[IPKernelApp] ERROR | Invalid Message
Traceback (most recent call last):
File "/home/luiz/anaconda/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 175, in dispatch_shell
msg = self.session.deserialize(msg, content=True, copy=False)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/session.py", line 870, in deserialize
return adapt(message)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/adapter.py", line 386, in adapt
header['date'] = datetime.now().isoformat()
NameError: global name 'datetime' is not defined
[IPKernelApp] ERROR | Invalid Message
Traceback (most recent call last):
File "/home/luiz/anaconda/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 175, in dispatch_shell
msg = self.session.deserialize(msg, content=True, copy=False)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/session.py", line 870, in deserialize
return adapt(message)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/adapter.py", line 386, in adapt
header['date'] = datetime.now().isoformat()
NameError: global name 'datetime' is not defined
What am I missing?
Oops, I needed to update some iPython dependencies. Problem solved!
Thanks!