Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0BB0E200BF7 for ; Mon, 9 Jan 2017 14:14:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0A662160B3B; Mon, 9 Jan 2017 13:14:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 31A35160B3E for ; Mon, 9 Jan 2017 14:14:03 +0100 (CET) Received: (qmail 96948 invoked by uid 500); 9 Jan 2017 13:14:02 -0000 Mailing-List: contact dev-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list dev@airflow.incubator.apache.org Received: (qmail 96937 invoked by uid 99); 9 Jan 2017 13:14:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jan 2017 13:14:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id A9C80C0EEA for ; Mon, 9 Jan 2017 13:14:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.98 X-Spam-Level: * X-Spam-Status: No, score=1.98 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id cznlsC6IIhGb for ; Mon, 9 Jan 2017 13:13:59 +0000 (UTC) Received: from mail-ua0-f179.google.com (mail-ua0-f179.google.com [209.85.217.179]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 9C3685FAC8 for ; Mon, 9 Jan 2017 13:13:58 +0000 (UTC) Received: by mail-ua0-f179.google.com with SMTP id i68so356916021uad.0 for ; Mon, 09 Jan 2017 05:13:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=rLRLePY6nj3s4TLkF3RFn+ooP9bYiYTWltlhUGEK2Vw=; b=Z7enGLhZO5Sb3Nq0oF3guDMQsxwIc4ZieR9UTw4H/PSCW0g8tM1xNVF2rKTJ/DGHt9 TbhXBNMe8kyK5Rpm3VZv8tA5Wesg8KT89q0oe4rRmKjyG8E4xVbxDuClermhwkEMbUf7 THwaklpt21au6Zb3h6cEz5JNgNA2htyFDlm8QVdYqOrJyzj0Tg/1l2GZh/pWbTMKX/db 1s3+gdmNupCOXLrGCQRPw9RC97eo3Umt5Uff+2E6/3qiLrP7OwDkmNIVdddrKlJbiTnj XDVzms//UfINf4rNxk4nw0Q/wRatwhQ/iQIX+av3j4SAT8aQZBRiVIeyRC8t7XZFC3hD M4Ig== X-Gm-Message-State: AIkVDXKyUYWbO+RinsP7YmEHWmhknLvwMGKa5c4BDv2e1NdRx0ACkXbCLrYD4y4XNm+uzlXf8JMrCdxa/7k0oQ== X-Received: by 10.176.0.143 with SMTP id 15mr17087553uaj.22.1483967628293; Mon, 09 Jan 2017 05:13:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Alex Van Boxel Date: Mon, 09 Jan 2017 13:13:37 +0000 Message-ID: Subject: Re: Refactoring Connection To: dev@airflow.incubator.apache.org Content-Type: multipart/alternative; boundary=001a113d729e57bb090545a92352 archived-at: Mon, 09 Jan 2017 13:14:04 -0000 --001a113d729e57bb090545a92352 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I was actually going to propose something different with entry-points, but your requirement beat me to it (but that's ok :-). Actually I think with this mechanism people would be able to extend Airflow connection mechanism (and later other stuff) by doing *pip install airflow-sexy-new-connection* (for example). On Mon, Jan 9, 2017 at 1:39 PM Gael Magnan wrote: > Thank you for the read, I'm gonna look at it, it's probably gonna be bett= er > that what I have. > > Point taken about the URI, I'll see if i can find something generic enoug= h > to handle all those cases. > > Le lun. 9 janv. 2017 =C3=A0 13:36, Alex Van Boxel a = =C3=A9crit : > > > Thanks a lot, yes it clarifies a lot and I do agree you really need to > hack > > inside Airflow to add a Connection type. While you're working at this > could > > you have a look at the standard python *entry-point mechanism* for > > registering Connection types/components. > > > > A good read on this: > > > > > http://docs.pylonsproject.org/projects/pylons-webframework/en/latest/adva= nced_pylons/entry_points_and_plugins.html > > > > My first though would be that just by adding an entry to the factory > method > > would be enough to register your Connection + ConnectionType and UI. > > > > Also note that not everything works with a URI. The Google Cloud > Connection > > doesn't have one, it uses a secret key file stored on disk, so don't > force > > every connection type to work with URI's. > > > > > > > > On Mon, Jan 9, 2017 at 1:15 PM Gael Magnan wrote= : > > > > > Yes sure, > > > > > > The question was the following: > > > "I was looking at the code of the connections, and I realized you can= 't > > > easily add a connection type without modifying the airflow code > source. I > > > wanted to create a mongodb connection type, but I think the best > approche > > > would be to refactor connections first. Thoughts anyone?" > > > > > > The answer of Bolke de Bruin was: "making it more generic would be > > > appreciated" > > > > > > So basically the way the code is set up actually every types of > > connection > > > existing is defined though a list in the Connection class. It > implements > > > exactly the same code for parsing uri to get connections info and > doesn't > > > allow for a simple way to get back the uri from the connection infos. > > > > > > I need to add a mongodb connection and a way to get it back as a uri, > so > > i > > > could use an other type of connection and play around with that or > juste > > > add one more hard coded connection type, but I though this might be > > > something that comes back regularly and having a simple way to plug i= n > > new > > > types of connection would make it easier for anyone to contribute a n= ew > > > connection type. > > > > > > Hope this clarifies my proposal. > > > > > > Le lun. 9 janv. 2017 =C3=A0 12:46, Alex Van Boxel = a > =C3=A9crit > > : > > > > > > > Hey Gael, > > > > > > > > could you please recap the question here and provide some context. > Not > > > > everyone on the mailinglist is actively following Gitter, including > me. > > > > With some context it would be easier to give feedback. Thanks. > > > > > > > > On Mon, Jan 9, 2017 at 11:15 AM Gael Magnan > > > wrote: > > > > > > > > > Hi, > > > > > > > > > > following my question on gitter the other day and the response fr= om > > > Bolke > > > > > de Bruin, I've started working on refactoring the connections in > > > airflow. > > > > > > > > > > Before submitting a PR I wanted to share my proposal with you and > get > > > > > feedbacks. > > > > > > > > > > The idea is quite simple, I've divided the Connection class in tw= o, > > > > > Connection and ConnectionType, connection has the same interface = it > > had > > > > > before plus a few methods, but the class keeps a reference to a > > > > dictionary > > > > > of registered ConnectionType. It delegates the work of parsing fr= om > > > URI, > > > > > formatting to URI (added) and getting the hook to the > ConnectionType > > > > > associated with the conn_type. > > > > > > > > > > I've thought of two ways of registering new ConnectionTypes, the > > first > > > is > > > > > making the BaseConnectionType use a metaclass that registered any > new > > > > > ConnectionType with Connection when the class is declared, it wou= ld > > > > require > > > > > the less work to extend the connection module, as just importing > the > > > file > > > > > with the connection would do the trick. > > > > > The second one is juste to have a function/classmethod that you > call > > > > > manually to register your connection. It would be simpler to > > understand > > > > but > > > > > requires more work every time you create a new ConnectionType. > > > > > > > > > > Hope this proposal is clear enough, and I'm waiting for feebacks > and > > > > > possible improvements. > > > > > > > > > > Regards > > > > > Gael Magnan de Bornier > > > > > > > > > -- > > > > _/ > > > > _/ Alex Van Boxel > > > > > > > > > -- > > _/ > > _/ Alex Van Boxel > > > --=20 _/ _/ Alex Van Boxel --001a113d729e57bb090545a92352--