{"action":"created","issue":{"url":"https://api.github.com/repos/apache/incubator-airflow/issues/1272","repository_url":"https://api.github.com/repos/apache/incubator-airflow","labels_url":"https://api.github.com/repos/apache/incubator-airflow/issues/1272/labels{/name}","comments_url":"https://api.github.com/repos/apache/incubator-airflow/issues/1272/comments","events_url":"https://api.github.com/repos/apache/incubator-airflow/issues/1272/events","html_url":"https://github.com/apache/incubator-airflow/pull/1272","id":145258574,"number":1272,"title":"[AIRFLOW-31] Use standard imports for hooks/operators","user":{"login":"jlowin","id":153965,"avatar_url":"https://avatars.githubusercontent.com/u/153965?v=3","gravatar_id":"","url":"https://api.github.com/users/jlowin","html_url":"https://github.com/jlowin","followers_url":"https://api.github.com/users/jlowin/followers","following_url":"https://api.github.com/users/jlowin/following{/other_user}","gists_url":"https://api.github.com/users/jlowin/gists{/gist_id}","starred_url":"https://api.github.com/users/jlowin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlowin/subscriptions","organizations_url":"https://api.github.com/users/jlowin/orgs","repos_url":"https://api.github.com/users/jlowin/repos","events_url":"https://api.github.com/users/jlowin/events{/privacy}","received_events_url":"https://api.github.com/users/jlowin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/apache/incubator-airflow/labels/Enhancement","name":"Enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/apache/incubator-airflow/labels/Needs%20Review","name":"Needs Review","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/apache/incubator-airflow/milestones/1","html_url":"https://github.com/apache/incubator-airflow/milestones/Airflow%202.0","labels_url":"https://api.github.com/repos/apache/incubator-airflow/milestones/1/labels","id":1672138,"number":1,"title":"Airflow 2.0","description":"","creator":{"login":"jlowin","id":153965,"avatar_url":"https://avatars.githubusercontent.com/u/153965?v=3","gravatar_id":"","url":"https://api.github.com/users/jlowin","html_url":"https://github.com/jlowin","followers_url":"https://api.github.com/users/jlowin/followers","following_url":"https://api.github.com/users/jlowin/following{/other_user}","gists_url":"https://api.github.com/users/jlowin/gists{/gist_id}","starred_url":"https://api.github.com/users/jlowin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlowin/subscriptions","organizations_url":"https://api.github.com/users/jlowin/orgs","repos_url":"https://api.github.com/users/jlowin/repos","events_url":"https://api.github.com/users/jlowin/events{/privacy}","received_events_url":"https://api.github.com/users/jlowin/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":2,"state":"open","created_at":"2016-03-29T15:47:15Z","updated_at":"2016-04-11T21:10:59Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2016-04-01T18:58:51Z","updated_at":"2016-06-17T03:24:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/incubator-airflow/pulls/1272","html_url":"https://github.com/apache/incubator-airflow/pull/1272","diff_url":"https://github.com/apache/incubator-airflow/pull/1272.diff","patch_url":"https://github.com/apache/incubator-airflow/pull/1272.patch"},"body":"See #1238 for details.\r\n\r\nThis PR replaces Airflow's import machinery with standard Python imports. This has an impact in four places:\r\n\r\n`airflow.hooks.*`\r\n`airflow.operators.*`\r\n`airflow.contrib.hooks.*`\r\n`airflow.contrib.operators.*`\r\n\r\nOperators that could formerly be accessed from these directories must now be accessed explicitly from submodules:\r\n\r\n```python\r\nfrom airflow.operators import PigOperator # NO\r\nfrom airflow.operators.pig_operator import PigOperator # YES\r\n```\r\n\r\nOld style imports *will still work* but will warn:\r\n\r\n```bash\r\nIn [4]: airflow.operators.PigOperator\r\n/Users/jlowin/anaconda3/bin/ipython:1: DeprecationWarning: PigOperator: Importing \r\nPigOperator directly from 'airflow.operators' has been deprecated. Please import \r\nfrom 'airflow.operators.[operator_module]' instead. Support for direct imports will \r\nbe dropped entirely in Airflow 2.0.\r\n  #!/bin/bash /Users/jlowin/anaconda3/bin/python.app\r\n\r\nOut[4]: pig_operator.PigOperator\r\n```\r\n\r\n`run_unit_tests.sh` exports an environment variable `AIRFLOW_USE_NEW_IMPORTS` which turns off the old-style (deprecated) imports completely. Therefore, unit tests must use the new style. **I've tried to adjust the tests already but there are some I can't test locally so I will see what Travis has issues with and make adjustments.**\r\n\r\nPlugins are handled similarly. Let's say the user creates a plugin `MyPlugin` with some operators. Currently those operators are available at `airflow.operators.*`. Through this PR, that behavior is maintained (through Airflow 2.0) but a new module is dynamically created with the operators at `airflow.operators.myplugin.*`\r\n\r\nLastly, I took advantage of the fact I was going into lots of files to add licenses to all hooks and operators.\r\n"},"comment":{"url":"https://api.github.com/repos/apache/incubator-airflow/issues/comments/226671678","html_url":"https://github.com/apache/incubator-airflow/pull/1272#issuecomment-226671678","issue_url":"https://api.github.com/repos/apache/incubator-airflow/issues/1272","id":226671678,"user":{"login":"criccomini","id":167569,"avatar_url":"https://avatars.githubusercontent.com/u/167569?v=3","gravatar_id":"","url":"https://api.github.com/users/criccomini","html_url":"https://github.com/criccomini","followers_url":"https://api.github.com/users/criccomini/followers","following_url":"https://api.github.com/users/criccomini/following{/other_user}","gists_url":"https://api.github.com/users/criccomini/gists{/gist_id}","starred_url":"https://api.github.com/users/criccomini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/criccomini/subscriptions","organizations_url":"https://api.github.com/users/criccomini/orgs","repos_url":"https://api.github.com/users/criccomini/repos","events_url":"https://api.github.com/users/criccomini/events{/privacy}","received_events_url":"https://api.github.com/users/criccomini/received_events","type":"User","site_admin":false},"created_at":"2016-06-17T03:24:42Z","updated_at":"2016-06-17T03:24:42Z","body":"Awesome! I'm +1 then. :)\r\n\r\nMake sure to squash the commits, though."}}
{"actor":{"display_login":"criccomini"}}