Skip to content

Commit

Permalink
Update Python katas to latest version of EduTools and Beam 2.41 (apac…
Browse files Browse the repository at this point in the history
…he#23180)

* Remove automatically generated files

The files *-remote-info.yaml are automatically generated by Edutools when a new
version of the course is generated (e.g. new package created for offline
distribution, or when a new version is uploaded to the courses marketplace).

* Update Python katas to latest version of EduTools

With the latest versions of the EduTools plugin, the previous katas stopped
working, and this made it impossible to release new versions of the
katas (e.g. after a new Beam release).

The main change is in the testing method. EduTools now uses Python's unittest
for checking the exercises.

I have also re-organized some of the katas (e.g. windowing and triggers are now
under the Streaming category), and updated the katas to Beam 2.41.

* Add missing license headers
  • Loading branch information
iht authored Sep 30, 2022
1 parent 31dab81 commit e6a7c50
Show file tree
Hide file tree
Showing 269 changed files with 2,468 additions and 1,712 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ website/www/yarn-error.log
**/*.tfstate.*
**/*.hcl
**/*.tfvars

# Ignore Katas auto-generated files
**/*-remote-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@
# specific language governing permissions and limitations
# under the License.
#

content:
- ParDo
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ files:
- offset: 1134
length: 31
placeholder_text: TODO()
- name: tests.py
- name: tests/test_task.py
visible: false
- name: __init__.py
visible: false
- name: tests/__init__.py
visible: false

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
(p | beam.Create(range(1, 11))
| beam.combiners.Count.Globally()
| LogElements())

33 changes: 0 additions & 33 deletions learning/katas/python/Common Transforms/Aggregation/Count/tests.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@
# specific language governing permissions and limitations
# under the License.
#

content:
- Fixed Time Window
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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.
#

import unittest

from test_helper import test_is_not_empty, get_file_output


class TestCase(unittest.TestCase):
def test_not_empty(self):
self.assertTrue(test_is_not_empty(), 'The output is empty')

def test_output(self):
output = get_file_output(path='task.py')

answer = '10'

self.assertIn(answer, output, "Incorrect output. Use the Count combiner.")
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ files:
- offset: 1150
length: 29
placeholder_text: TODO()
- name: tests.py
- name: tests/test_task.py
visible: false
- name: __init__.py
visible: false
- name: tests/__init__.py
visible: false

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
(p | beam.Create(range(1, 11))
| beam.combiners.Top.Largest(2)
| LogElements())

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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.
#

import unittest

from test_helper import test_is_not_empty, get_file_output


class TestCase(unittest.TestCase):
def test_not_empty(self):
self.assertTrue(test_is_not_empty(), 'The output is empty')

def test_output(self):
output = get_file_output(path='task.py')

answer = '[10, 9]'

self.assertIn(answer, output, "Incorrect output. Use the Top.Largest combiner.")
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ files:
- offset: 1156
length: 30
placeholder_text: TODO()
- name: tests.py
- name: tests/test_task.py
visible: false
- name: __init__.py
visible: false
- name: tests/__init__.py
visible: false

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
(p | beam.Create(range(1, 11))
| beam.combiners.Mean.Globally()
| LogElements())

33 changes: 0 additions & 33 deletions learning/katas/python/Common Transforms/Aggregation/Mean/tests.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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.
#

import unittest

from test_helper import test_is_not_empty, get_file_output


class TestCase(unittest.TestCase):
def test_not_empty(self):
self.assertTrue(test_is_not_empty(), 'The output is empty')

def test_output(self):
output = get_file_output(path='task.py')

answer = '5.5'

self.assertIn(answer, output, "Incorrect output. Use the Mean combiner.")
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ files:
- offset: 1141
length: 30
placeholder_text: TODO()
- name: tests.py
- name: tests/test_task.py
visible: false
- name: __init__.py
visible: false
- name: tests/__init__.py
visible: false

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
(p | beam.Create(range(1, 11))
| beam.combiners.Top.Smallest(1)
| LogElements())

Loading

0 comments on commit e6a7c50

Please sign in to comment.