python-lambda-local self = reduction.pickle.load(from_parent) - python-3.7

[root - INFO - 2019-02-11 17:40:38,224] Event: {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
[root - INFO - 2019-02-11 17:40:38,224] START RequestId: f294f11b-4c1e-46f7-b434-e78eb7d9e8ba Version:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Sekhar.Changalaraya\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Users\Sekhar.Changalaraya\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
ModuleNotFoundError: No module named 'request-f294f11b-4c1e-46f7-b434-e78eb7d9e8ba'
def handler(event, context):
return {'statusCode': 200, 'body': 'd'}

Use python-lambda-local==0.1.7 or python-lambda-local==0.1.6

It should already be fixed with v0.1.12 of python-lambda-local.

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

Airflow - email operator sending multiple files issue

I am using airflow 2.2. I am trying to send multiple files using airflow email operator. the files list will be generated dynamically and using XCom pull to get the list of files from the previous task. For some reason, email operator files parameter is NOT able to read the files list from XCom value. Kindly advise.
Error details:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/airflow/task/task_runner/standard_task_runner.py", line 85, in _start_by_fork
args.func(args, dag=self.dag)
File "/usr/local/lib/python3.7/site-packages/airflow/cli/cli_parser.py", line 48, in command
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/airflow/utils/cli.py", line 92, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/airflow/cli/commands/task_command.py", line 292, in task_run
_run_task_by_selected_method(args, dag, ti)
File "/usr/local/lib/python3.7/site-packages/airflow/cli/commands/task_command.py", line 107, in _run_task_by_selected_method
_run_raw_task(args, ti)
File "/usr/local/lib/python3.7/site-packages/airflow/cli/commands/task_command.py", line 184, in _run_raw_task
error_file=args.error_file,
File "/usr/local/lib/python3.7/site-packages/airflow/utils/session.py", line 70, in wrapper
return func(*args, session=session, **kwargs)
File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1332, in _run_raw_task
self._execute_task_with_callbacks(context)
File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1458, in _execute_task_with_callbacks
result = self._execute_task(context, self.task)
File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1514, in _execute_task
result = execute_callable(context=context)
File "/usr/local/lib/python3.7/site-packages/airflow/operators/email.py", line 88, in execute
conn_id=self.conn_id,
File "/usr/local/lib/python3.7/site-packages/airflow/utils/email.py", line 66, in send_email
**kwargs,
File "/usr/local/lib/python3.7/site-packages/airflow/utils/email.py", line 99, in send_email_smtp
mime_charset=mime_charset,
File "/usr/local/lib/python3.7/site-packages/airflow/utils/email.py", line 157, in build_mime_message
with open(fname, "rb") as file:
FileNotFoundError: [Errno 2] No such file or directory: '['
[2022-09-18, 17:24:22 UTC] {{local_task_job.py:154}} INFO - Task exited with return code 1
[2022-09-18, 17:24:23 UTC] {{local_task_job.py:264}} INFO - 0 downstream tasks scheduled from follow-on schedule check
from airflow import DAG
from airflow.operators.email import EmailOperator
from airflow.operators.python import PythonOperator
import os
from datetime import datetime, timedelta
default_args = {
"owner": 'TEST',
"depends_on_past": False,
"email_on_failure": False,
"email_on_retry": False,
"retries": 0,
}
with DAG(
dag_id="test9_email_operator_dag",
default_args=default_args,
start_date=datetime(2022, 9, 14),
end_date=datetime(2022, 9, 15),
catchup=True,
max_active_runs=1,
schedule_interval="0 12 * * *", # Runs every day # 8AM EST
) as dag:
def print_local_folder_files(local_temp_folder):
print("local folder files => ", os.listdir(local_temp_folder))
files_list = []
for file in os.listdir(local_temp_folder):
files_list.append(local_temp_folder + file)
print("files_list => ", files_list)
return files_list
print_local_folder_files = PythonOperator(
task_id='print_local_folder_files',
python_callable=print_local_folder_files,
op_kwargs={'local_temp_folder': "/usr/local/airflow/dags/temp_dir/"},
do_xcom_push=True,
provide_context=True,
dag=dag)
send_email = EmailOperator(
task_id='send_email',
to='test#gmail.com',
subject='Test Email op Notification',
html_content='Test email op notification email. ',
files="{{ task_instance.xcom_pull(task_ids='print_local_folder_files') }}"
)
print_local_folder_files >> send_email
You pushed a list to Xcom but Xcoms are rendered as string by default so what you have there is a string representation of list. This is why when you try to read it you get the first char because when you iterate over a string you get it char by char.
To solve your issue you should set render_template_as_native_obj=True on the DAG object:
with DAG(
dag_id="test9_email_operator_dag",
...,
render_template_as_native_obj=True,
) as dag:
This will let Jinja engine know that you expect to render as native Python types so you will get a list rather than a string.
For more information check Airflow docs on this feature.

Error 'str' object has no attribute 'is_stale'

After calling this method it shows me this error 'str' object has no attribute 'is_stale': response = client.get_products(37.77, -122.41)
this is source code:
import sys from uber_rides.session
import Session from uber_rides.client
import UberRidesClient
session = Session(oauth2credential='[redacted]')
client = UberRidesClient(session)
response = client.get_products(37.77, -122.41)
Traceback:
Traceback (most recent call last):
File "/Users/mhv/Projects/Other/Python/Uber/main.py", line 12, in <module>
response = client.get_products(37.77, -122.41)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uber_rides/client.py", line 128, in get_products
return self._api_call('GET', 'v1.2/products', args=args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uber_rides/client.py", line 96, in _api_call
self.refresh_oauth_credential()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uber_rides/client.py", line 720, in refresh_oauth_credential
if credential.is_stale():
AttributeError: 'str' object has no attribute 'is_stale'
Best regards

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

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'

Docker-compose: AttributeError: 'module' object has no attribute 'ssl'

Today I have tried use docker-compose and got next error:
>>docker-compose
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 9, in <module>
load_entry_point('docker-compose==1.7.1', 'console_scripts', 'docker-compose')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 14, in <module>
from . import errors
File "/usr/lib/python2.7/site-packages/compose/cli/errors.py", line 9, in <module>
from docker.errors import APIError
File "/usr/lib/python2.7/site-packages/docker/__init__.py", line 20, in <module>
from .client import Client, AutoVersionClient, from_env # flake8: noqa
File "/usr/lib/python2.7/site-packages/docker/client.py", line 22, in <module>
import websocket
File "/usr/lib/python2.7/site-packages/websocket/__init__.py", line 22, in <module>
from ._core import *
File "/usr/lib/python2.7/site-packages/websocket/_core.py", line 39, in <module>
from ._socket import *
File "/usr/lib/python2.7/site-packages/websocket/_socket.py", line 28, in <module>
from ._ssl_compat import *
AttributeError: 'module' object has no attribute 'ssl'
OS: OpenSuse Leap 42.1
Docker-compose: 1.7.1
Docker: 1.11.2
libopenssl-devel installed
Downgrade OpennSSL to version 1.0.1i-15.1 from 1.0.1i-2.36.1 has fixed my problem.