Airflow authentication setups fails with "AttributeError: can't set attribute" - airflow

The Airflow version 1.8 password authentication setup as described in the docs fails at the step
user.password = 'set_the_password'
with error
AttributeError: can't set attribute

It's better to simply use the new method of PasswordUser _set_password:
# Instead of user.password = 'password'
user._set_password = 'password'

This is due to an update of SqlAlchemy to a version >= 1.2 that introduced a backwards incompatible change.
You can fix this by explicitly installing a SqlAlchemy version <1.2.
pip install 'sqlalchemy<1.2'
Or in a requirement.txt
sqlalchemy<1.2

Fixed with
pip install 'sqlalchemy<1.2'
I'm using apache-airflow 1.8.2

In case anyone's curious about what the incompatible change in SQLAlchemy 1.2 (mentioned in #DanT's answer) actually is, it is a change in how SQLAlchemy deals with hybrid proprerties. Beginning in 1.2, methods have to have the same name as the original hybrid, which was not required before. The fix for Airflow is very simple. The code in contrib/auth/backends/password_auth.py should change from this:
#password.setter
def _set_password(self, plaintext):
self._password = generate_password_hash(plaintext, 12)
if PY3:
self._password = str(self._password, 'utf-8')
to this:
#password.setter
def password(self, plaintext):
self._password = generate_password_hash(plaintext, 12)
if PY3:
self._password = str(self._password, 'utf-8')
See https://bitbucket.org/zzzeek/sqlalchemy/issues/4332/hybrid_property-gives-attributeerror for more details.

Related

pkgdown::deploy_to_branch() SSL cert error

I've been using pkgdown::deploy_to_branch() for awhile now to publish my docs on the gh-pages branch of my repo, but as of this week it stopped working and has started giving me the following error:
Error: callr subprocess failed: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
Type .Last.error.trace to see where the error occurred
7.
stop(cond) at errors.R#275
6.
throw(newerr, parent = remerr[[2]]) at result.R#70
5.
get_result(output = out, options) at eval.R#176
4.
callr::r(function(..., crayon_enabled, crayon_colors, pkgdown_internet) {
options(crayon.enabled = crayon_enabled, crayon.colors = crayon_colors,
pkgdown.internet = pkgdown_internet)
pkgdown::build_site(...) ... at build.r#432
3.
build_site_external(pkg = pkg, examples = examples, run_dont_run = run_dont_run,
seed = seed, lazy = lazy, override = override, preview = preview,
devel = devel) at build.r#385
2.
build_site(pkg, devel = FALSE, preview = FALSE, install = FALSE,
...) at deploy-site.R#172
1.
pkgdown::deploy_to_branch()
When I tried to debug and got deeper into the function, this is the error I got trying to call build_site() directly:
Admittedly, authentication of all sorts is consistently baffling to me, but what has me really baffled is that my auth with github seems to be working in all other ways. I have it cloned with SSH. I can push and pull to my heart's content when I do it manually or through the RStudio GUI. Also, I can't figure out anything that has changed since the time when this was working.
Anyway, any help is much appreciated. I've also looked at a few other issues that came up when I googled the error (this one, for example) but none of them seem to be relevant to my situation where git is working fine except in this call.
Some details:
I'm on Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-1054-aws x86_64)
R 4.0.3
pkgdown 1.6.1
I tried this with two different repos (1 and 2, both of which were previously working with this same command and the same OS/versions/etc ^
Let me know if there are any more details that would help. Thanks!
Well, it turns out this had nothing to do with pkgdown. Sorry for blaming you pkgdown!
The issue had something to do with this which I was lucky enough to stumble onto the exact day that it happened. A coworker told me to run the following snippet and it fixed everything.
sudo apt-get update ; sudo apt-get install -y ca-certificates

Mindmeld gazetteer build failes with 'list' object has no attribute 'get'

Following docs from mindmeld.com(Step 7):
from mindmeld.components.nlp import NaturalLanguageProcessor
nlp = NaturalLanguageProcessor('.')
nlp.build()
Results in error:
self.build_gazetteer(gaz_name, force_reload=force_reload)
File "/home/sar/test/lib/python3.6/site-packages/mindmeld/resource_loader.py", line 214, in
build_gazetteer
mapping.get("entities", []), self.query_factory.normalize
AttributeError: 'list' object has no attribute 'get'
Obviously, list has no .get(), I assume nlp.build() should have made a dictionary, but fails to do so. Anyone else experienced this? Tested on Ubuntu 18.04, Python 3.6.9.
EDIT: Found this old post of mine, worked it out. I don't remember details, but nlp doesn't support Python > 3.7, custom Python version in virtual environment fixed this.
problem was incompatible Python version for MindMeld, using Python 3.6 or 3.7 fixed this

Is CPlex Optimization Studio 12.9.0 compatible with Python notebooks for APIs. If yes, which version of Python?

I have installed Cplex (Optimization Studio 12.9.0 - Community Edition) and need to write Python APIs in it.
After installing setup.py as per https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.2/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Python_setup.html?view=embed,
I get error that
DOcplexException: CPLEX runtime not found: please install CPLEX or
solve this model on DOcplexcloud
How can i solve this error?
Have you set the Python path environment variable PYTHONPATH to the value of yourCplexhome/python/VERSION/PLATFORM?
Or you could try to use docplexcloud. For instance the following example from https://www.ibm.com/developerworks/community/forums/html/topic?id=80146d62-1e2b-490e-b5f8-6fbf38a51e18&ps=25
from docplex.mp.model import Model
from docplex.mp.context import Context
url = "https://api-oaas.docloud.ibmcloud.com/job_manager/rest/v1"
key = "YOUR API KEY"
ctx = Context.make_default_context(url=url, key=key)
mdl = Model(name='buses',context=ctx)
mdl.nbbus40 = mdl.integer_var(name='nbBus40')
mdl.nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(mdl.nbbus40*40 + mdl.nbbus30*30 >= 300, 'kids')
mdl.minimize(mdl.nbbus40*500 + mdl.nbbus30*400)
mdl.solve()
print(mdl.nbbus40.solution_value);
print(mdl.nbbus30.solution_value);
This works fine.

Issue with R - Shiny command runGitHub() [duplicate]

I am trying to install a sample package from my github repo:
https://github.com/jpmarindiaz/samplepkg
I can install it when the repo is public using any of the following commands through the R interpreter:
install_github("jpmarindiaz/rdali")
install_github("rdali",user="jpmarindiaz")
install_github("jpmarindiaz/rdali",auth_user="jpmarindiaz")
But when the git repository is private I get an Error:
Installing github repo samplepkg/master from jpmarindiaz
Downloading samplepkg.zip from
https://github.com/jpmarindiaz/samplepkg/archive/master.zip
Error: client error: (406) Not Acceptable
I haven't figured out how the authentication works when the repo is private, any hints?
Have you tried setting a personal access token (PAT) and passing it along as the value of the auth_token argument of install_github()?
See ?install_github way down at the bottom (Package devtools version 1.5.0.99).
Create an access token in:
https://github.com/settings/tokens
Check the branch name and pass it to ref
devtools::install_github("user/repo"
,ref="main"
,auth_token = "tokenstring"
)
A more modern solution to this problem is to set your credentials in R using the usethis and credentials packages.
#set config
usethis::use_git_config(user.name = "YourName", user.email = "your#mail.com")
#Go to github page to generate token
usethis::create_github_token()
#paste your PAT into pop-up that follows...
credentials::set_github_pat()
#now remotes::install_github() will work
remotes::install_github("username/privaterepo")
More help at https://happygitwithr.com/common-remote-setups.html#common-remote-setups

grpc.Credentials.createSsl() - Cannot read property 'createSsl' of undefined

I am getting following error running nodejs (latest stable) & grpc (installed via npm install grpc) on win7 x64:
Relevant code:
var certPath = path.join(process.env.LOCALAPPDATA, 'cert', 'rpc.cert');
var cert = fs.readFileSync(certPath);
var creds = grpc.Credentials.createSsl(cert);
Error:
var creds = grpc.Credentials.createSsl();
^
TypeError: Cannot read property 'createSsl' of undefined
rpc.cert is present in the path and is readable + is in PEM standard format. I guess, gRPC is throwing error, because it does not understand the format maybe ? Or what I am doing wrong here - or what am I missing ?
Thank you very much for any help!
This is actually just a minor API usage error. Some time within the last couple of versions, grpc.Credentials changed to grpc.credentials (with a lower-case c). You should be able to call grpc.credentials.createSsl() just fine.

Resources