While airflow initdb, AttributeError: module' object has no attribute 'client_auth' - python-2.7

I have recently installed apache airflow 1.8.1, I executed following command:
airflow initdb
which returned following error:
Traceback (most recent call last):
File "/usr/bin/airflow", line 18, in <module>
from airflow.bin.cli import CLIFactory
File "/usr/lib/python2.7/dist-packages/airflow/bin/cli.py", line 65, in <module>
auth=api.api_auth.client_auth)
AttributeError: 'module' object has no attribute 'client_auth'
I tried several solutions but it doesn't work.

I figured out what we were doing wrong. The field auth_backend=airflow.contrib.auth.backends.password_auth needs to be under webserver and not under api. Add it if it is not already there. There are multiple fields for auth_backend as there are authenticate etc..

I had the same error with airflow 1.8.1 with python 2.7.11.
I have disabled the webserver auth ( temporarily) and switched to the default value for auth_backend. ( that solved the issue)
The final configuration in my airflow.cfg is as follows
auth_backend = airflow.api.auth.backend.default
authenticate = False

Related

Accessing Mailman 3 list members via Python/Django management console

I am trying to access members of an existing Mailman 3 mailing list directly from Django Management console on a Debian Bullseye where Mailman is installed from deb packages (mailman3-full). I can connect to the Django admin console like this (all 3 variants seem to work fine):
$ /usr/share/mailman3-web/manage.py shell
$ mailman-web shell
$ mailman-web shell --settings /etc/mailman3/mailman-web.py
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
>>>
But inside the Django admin console, some mailman components seem to be missing.
I try to access the list manager as described here: Docs > Models > The mailing list manager:
>>> from mailman.interfaces.listmanager import IListManager
>>> from zope.component import getUtility
>>> list_manager = getUtility(IListManager)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass mailman.interfaces.listmanager.IListManager>, '')
Can't figure out why this ComponentLookupError happens.
Also tried to acccess a list with the ListManager implementation:
>>> from mailman.config import config
>>> from mailman.model.listmanager import ListManager
>>> list_manager = ListManager()
>>> list_manager.get('mynews#example.com')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/mailman/database/transaction.py", line 85, in wrapper
return function(args[0], config.db.store, *args[1:], **kws)
AttributeError: 'NoneType' object has no attribute 'store'
>>> list_manager.get_by_list_id('mynews.example.com')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/mailman/database/transaction.py", line 85, in wrapper
return function(args[0], config.db.store, *args[1:], **kws)
AttributeError: 'NoneType' object has no attribute 'store'
What am I doing wrong here? None of the examples in the Mailman 3 models documentation is working if I don't even get that far.
any help greatly appreciated!
It's just the wrong shell you are using. You should use Mailman core shell instead.
It is accessible via just mailman shell in your system most probably.
So mailman shell works great and I could run this interactively:
from mailman.interfaces.listmanager import IListManager
from zope.component import getUtility
from mailman.testing.documentation import dump_list
from operator import attrgetter
def dump_members(roster):
all_addresses = list(member.address for member in roster)
sorted_addresses = sorted(all_addresses, key=attrgetter('email'))
dump_list(sorted_addresses)
list_manager = getUtility(IListManager)
mlist = list_manager.get('ant#example.com')
dump_members(mlist.members.members)
but how could I put this into a script that could be run with mailman withlist -r listmembers -l ant#example.com?
from mailman.testing.documentation import dump_list
from operator import attrgetter
def listmembers(mlist):
roster = mlist.members.members
all_addresses = list(member.address for member in roster)
sorted_addresses = sorted(all_addresses, key=attrgetter('email'))
dump_list(sorted_addresses)
where would I put such a listmembers.py runner? I tried to put it into /usr/lib/python3/dist-packages/mailman/runners directory, but didn't work:
$ mailman withlist -r listmembers -l ant#example.com
ModuleNotFoundError: No module named 'listmembers'
Thanks!

Missing XLA configuration when running pytorch/xla

I am trying to run GCP TPU with Pytorch/XLA, I am using a VM with debian-9-torch-xla-v20200818 image, I initiate the TPU and check it is running using ctpu status which shows that both the CPU and TPU are running, I then activate the torch-xla-nightly environment, but when I try to invoke this simple code:
import torch
import torch_xla
import torch_xla.core.xla_model as xm
dev = xm.xla_device()
t1 = torch.ones(3, 3, device = dev)
print(t1)
this error comes up:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/core/xla_model.py", line 231, in xla_device
devkind=devkind if devkind is not None else None)
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/core/xla_model.py", line 136, in get_xla_supported_devices
xla_devices = _DEVICES.value
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/utils/utils.py", line 32, in value
self._value = self._gen_fn()
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/core/xla_model.py", line 18, in <lambda>
_DEVICES = xu.LazyProperty(lambda: torch_xla._XLAC._xla_get_devices())
RuntimeError: tensorflow/compiler/xla/xla_client/computation_client.cc:274 : Missing XLA configuration
I tried everything but nothing seem to work.
Take a look at this link as it seems to pertain to the issue. Maybe you didn't setup the XRT_TPU_CONFIG: (vm)$ export XRT_TPU_CONFIG="tpu_worker;0;$TPU_IP_ADDRESS:8470" Follow the instructions here and you should be fine.
Another possibility if you see that XRT_TPU_CONFIG set properly is that you forgot to start your instance with the appropriate scopes:
gcloud compute instances create ... --scopes=https://www.googleapis.com/auth/cloud-platform

Error in gcloud " AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'"

I am trying to implement firebase functions cron job from this link : https://github.com/firebase/functions-cron
Everything worked properly
But when I try to run google cloud cron job it gives me below error :
(/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
I tried this solution : Getting AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS' when running Google Sheets API quickstart
But still no luck.
Can anyone please help me with this.
Issue is with your httplib Module.
When you installed this module for your project you must have installed it with pip for Python 3
If you want to check whether this module is for python 3 or python 2,
Go to httplib2 module and go inside its init.py
later see this line Requires Python 3 or later
if it is written like that means you have installed this library with pip for python 3. Now delete all the httplib2 from your lib folder.
Create a seperate enviroment for python 2.7 and again install all your modules with pip install -t lib -r requirements.txt

Boto and Python on AWS

I am trying to get boto to work, but I am getting an error.
Installed boto via easy_install, or simply python ./setup.py install
cat boto.py
#!/usr/bin/python
import boto
conn = boto.connect_ec2()
3c075474c10b% ./boto.py
Traceback (most recent call last):
File "./boto.py", line 2, in <module>
import boto
File "/Users/vasiliyb/scripts/boto.py", line 3, in <module>
conn = boto.connect_ec2()
AttributeError: 'module' object has no attribute 'connect_ec2'
Just change the name of your module from "boto.py" to "myboto.py" (or whatever you like) and it will magically work.
You are basically redefining "boto" by naming your module boto.py.

'RegistrationTestModel has no attribute '_deferred'

I am trying to get the Django Shell working with the Google App Engine. Unfortunately, I am getting the following error:
AttributeError: type object 'RegistrationTestModel' has no attribute '_deferred'
Does anyone have any idea of how to fix this?
Stack trace:
WARNING:root:Could not read datastore data from /var/folders/X0/X0QgAfs7Hd8IcCVZOIkiCE+++TI/-Tmp-/django_content-sharer.datastore
WARNING:root:Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
Traceback (most recent call last):
File "manage.py", line 30, in <module>
execute_manager(settings)
File "/Users/chris/Documents/workspace/ContentSharer/src/__init__.py", line 362, in execute_manager
File "/Users/chris/Documents/workspace/ContentSharer/src/__init__.py", line 303, in execute
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 195, in run_from_argv
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 222, in execute
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 351, in handle
File "/Users/chris/Documents/workspace/ContentSharer/src/django/core/management/commands/shell.py", line 18, in handle_noargs
loaded_models = get_models()
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/db/models/loading.py", line 166, in get_models
AttributeError: type object 'RegistrationTestModel' has no attribute '_deferred'
Are you using Django 1.1.2 with the helper? If so, the helper has not yet been updated for Django 1.1.2 yet. Be sure to get r105 or later of the helper. As a side note, Django 1.1.2 hasn't been installed on production for use_library yet, as far as I know.
Try using Django 1.1.1 until 1.1.2 is available on GAE production and the helper has been updated.
Patch is included in this ticket: http://code.google.com/p/google-app-engine-django/issues/detail?id=171
Update: the helper has been patched with r105 http://code.google.com/p/google-app-engine-django/source/detail?r=105
It looks like you're trying to load a part of Django that depends on Django models. Django models do not work on App Engine, as they depend on a relational database.
Try django-nonrel instead.