You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/04 01:29:48 UTC

[GitHub] [airflow] potiuk opened a new pull request #9132: Split utils sh

potiuk opened a new pull request #9132:
URL: https://github.com/apache/airflow/pull/9132


   Please take a look at the last commit. It is based on #9130 
   
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Target Github ISSUE in description if exists
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backward-incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435292192



##########
File path: scripts/ci/libraries/_remove_images.sh
##########
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Removes airflow CI and base images
+function remove_all_images() {

Review comment:
       Yeah. Push and remove were small. I combined them all into _push_pull_remove_images.sh. Since we also have _build_images.sh (and these have quite a bit more complex logic) I think it makes sense to split them this way.
   
   I also considered splitting it across prod/ci images but there are too many common parts in build to split it further.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435332890



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       > BASH_SOURCE[0] is the current file -- the equivalent of `__file__` in python:
   
   Hmmm. Indeed. I was living under the impression than when you `source` the script, it is inlined in the original script. I had similar problems before but I think the reason was different - abusing _MY_DIR variable. I changed it. 
   
   Thanks!. Again seems that with bash even after xxx years  you learn every day.
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435082218



##########
File path: scripts/ci/libraries/_remove_images.sh
##########
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Removes airflow CI and base images
+function remove_all_images() {

Review comment:
       What do you tink of having this, _push.sh and _pull.sh all in a single _images.sh file?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#issuecomment-638919442


   > @potiuk we probably want to run all tests on this btw.
   
   Good point. I updated the pattern in ci.yml to also trigger test builds on any change in "scripts" :).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435323454



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       BASH_SOURCE[0] is the current file -- the equivalent of `__file__` in python:
   
   ```
   airflow ❯ cat test.sh
   . $( dirname "${BASH_SOURCE[0]}" )/tmp/test.sh
   
   airflow ❯ cat tmp/test.sh
   set -x
   SCRIPTS_CI_DIR="$( dirname "${BASH_SOURCE[0]}" )"
   echo BASH_SOURCE is "${BASH_SOURCE[@]}"
   
   
   airflow ❯ bash -x test.sh
   ++ dirname ./test.sh
   + . ./tmp/test.sh
   ++ set -x
   +++ dirname ./tmp/test.sh
   ++ SCRIPTS_CI_DIR=./tmp
   ++ echo BASH_SOURCE is ./tmp/test.sh ./test.sh
   BASH_SOURCE is ./tmp/test.sh ./test.sh
   ```
   
   And it works when run from somewhere else too:
   
   ```
   airflow ❯ cd airflow && bash -x ../test.sh
   ++ dirname ../test.sh
   + . ../tmp/test.sh
   ++ set -x
   +++ dirname ../tmp/test.sh
   ++ SCRIPTS_CI_DIR=../tmp
   ++ echo BASH_SOURCE is ../tmp/test.sh ../test.sh
   BASH_SOURCE is ../tmp/test.sh ../test.sh
   
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] dimberman commented on pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
dimberman commented on pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#issuecomment-638902890


   @potiuk we probably want to run all tests on this btw.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk merged pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #9132:
URL: https://github.com/apache/airflow/pull/9132


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435324353



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       (The `:` to do nothing, and the `${VAR:?Error message}` are both hard to understand until you know what they do, so I don't mind us not using those)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435288550



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       Nice. You learn every day :). 
   
   I usally prefer to be a bit more explicit ifs rather than idiomatic bash constructs and add empty lines (they make error a bit more readable), but since this one provides also line number + script, it's much better. I will add it in couple more places :).
   
   We need it because this will only works if we source that file from a bash script running in the "scripts/ci" directory. If we source it from ./breeze which is two levels up , the `$(dirname "${BASH_SOURCE[0]}"` returns the top level airflow sources directory.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435080920



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       That said, why don't we do it automatically?
   
   ```
    SCRIPTS_CI_DIR="$( dirname "${BASH_SOURCE[0]}" )"
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435080310



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       FYI bash has something like this built in:
   
   ```suggestion
   : "${SCRIPTS_CI_DIR:?this variable must be set before sourcing this file}"
   ```
   
   Example usage:
   
   ```
   ❯ cat test.sh
   set -euo pipefail
   : "${SCRIPTS_CI_DIR:?this variable must be set before sourcing this file}"
   
   ❯ bash ./test.sh
   ./test.sh: line 2: SCRIPTS_CI_DIR: this variable must be set before sourcing this file
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#issuecomment-638548194


   Following the discussion with @dimberman (and recent slack conversation with @ashb about `utils` as being bad name) -> I split the _utils.sh into meaningful and much smaller libraries - each responsible for pretty much one thing only.
   
   It should be much easier to understand what's going on and where to search for corresponding part of the bash script. If we ever decide to reimplement some parts of it in a different languages, that might also be good idea to understand what Breeze and the scripts are actually doing.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9132: Split utils sh

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9132:
URL: https://github.com/apache/airflow/pull/9132#discussion_r435333432



##########
File path: scripts/ci/_all_libs.sh
##########
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# SCRIPTS_CI_DIR must be set
+
+if [[ "${SCRIPTS_CI_DIR}" == "" ]]; then
+        echo 2>&1
+        echo 2>&1 "Error - the script should have  SCRIPTS_CI_DIR variable set!"
+        echo 2>&1
+        exit 1
+fi

Review comment:
       And I am ok with :? - it gives line number which is really nice. And it's pretty obvious what it does if you start your message with "ERROR!".




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org