8000 Test Composer samples on Python 3 (#1688) · rlkelly/python-docs-samples@fb7bdb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb7bdb5

Browse files
authored
Test Composer samples on Python 3 (GoogleCloudPlatform#1688)
* Test Composer samples on Python 3 Note: I had to skip the use_local_deps workflow sample because of a change in relative versus absolute imports between Python 2 and Python 3. I have not yet checked the workflow within Airflow to see if it runs under Python 3. * Composer: Use slugify for unicode. Run local deps test in Python 3.
1 parent 16de3b4 commit fb7bdb5

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

.kokoro/presubmit_tests_composer.cfg

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,13 @@ env_vars: {
1111

1212
env_vars: {
1313
key: "NOX_SESSION"
14-
value: "composer and py27 and not appengine"
14+
value: "composer and py36 and not appengine"
15+
}
16+
17+
# Explicitly use choose unicode dependency to let the apache-airflow package
18+
# installation continue. See:
19+
# https://github.com/apache/incubator-airflow/pull/3660
20+
env_vars: {
21+
key: "SLUGIFY_USES_TEXT_UNIDECODE"
22+
value: "yes"
1523
}

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ cache:
1212
- "$HOME/.cache"
1313
env:
1414
global:
15+
# Explicitly use choose unicode dependency to let the apache-airflow
16+
# package installation continue. See:
17+
# https://github.com/apache/incubator-airflow/pull/3660
18+
- SLUGIFY_USES_TEXT_UNIDECODE=yes
1519
secure: fsBH64/WqTe7lRcn4awZU7q6+euS/LHgMq2Ee2ubaoxUei2GbK5jBgnGHxOKVL5sZ4KNfTc7d6NR5BB1ZouYr2v4q1ip7Il9kFG4g5qV4cIXzHusXkrjvIzQLupNpcD9JJZr1fmYh4AqXRs2kP/nZqb7xB6Jm/O+h+aeC1bhhBg=
1620
addons:
1721
apt:

composer/workflows/use_local_deps_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os.path
16+
import sys
17+
18+
import pytest
19+
20+
21+
@pytest.fixture(scope='module', autouse=True)
22+
def local_deps():
23+
"""Add local directory to the PYTHONPATH to allow absolute imports.
24+
25+
Relative imports do not work in Airflow workflow definitions.
26+
"""
27+
workflows_dir = os.path.abspath(os.path.dirname(__file__))
28+
sys.path.append(workflows_dir)
29+
yield
30+
sys.path.remove(workflows_dir)
31+
1532

1633
def test_dag_import():
1734
"""Test that the DAG file can be successfully imported.

nox.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ def _setup_appengine_sdk(session):
157157
GAE_STANDARD_SAMPLES = [
158158
sample for sample in ALL_TESTED_SAMPLES
159159
if sample.startswith('./appengine/standard/')]
160-
PY2_ONLY_SAMPLES = GAE_STANDARD_SAMPLES + [
161-
sample for sample in ALL_TESTED_SAMPLES
162-
if sample.startswith('./composer/workflows')]
160+
PY2_ONLY_SAMPLES = GAE_STANDARD_SAMPLES
163161
PY3_ONLY_SAMPLES = [
164162
sample for sample in ALL_TESTED_SAMPLES
165163
if (sample.startswith('./appengine/standard_python37')

testing/test-env.tmpl.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Environment variables for system tests.
22
export GCLOUD_PROJECT=your-project-id
3+
export GOOGLE_CLOUD_PROJECT=$GCLOUD_PROJECT
34
export CLOUD_STORAGE_BUCKET=$GCLOUD_PROJECT
45
export API_KEY=
56
export BIGTABLE_CLUSTER=bigtable-test

0 commit comments

Comments
 (0)
0