Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hw] Introduce StrEnum and IntEnum classes to resolve unit test failures with Python 3.11+ #5397

Merged
merged 11 commits into from
Sep 9, 2024

Conversation

csharplus
Copy link
Collaborator

Description

Fix the following unit test failure when running with Python 3.11+. More background information about this issue is discussed in mobilityhouse/ocpp#447.

FAIL: test_create_endpoint_dbt_yaml_with_parent_pipelines (tests.api.endpoints.test_blocks.DBTBlockAPIEndpointTest.test_create_endpoint_dbt_yaml_with_parent_pipelines)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/unittest/async_case.py", line 90, in _callTestMethod
    if self._callMaybeAsync(method) is not None:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/unittest/async_case.py", line 112, in _callMaybeAsync
    return self._asyncioRunner.run(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/hw/workspace/dev/mage-ai/mage_ai/tests/api/endpoints/mixins.py", line 247, in _test_create_endpoint
    await self.build_test_create_endpoint(
  File "/Users/hw/workspace/dev/mage-ai/mage_ai/tests/api/endpoints/mixins.py", line 813, in build_test_create_endpoint
    validation = assert_after_create_count(self)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hw/workspace/dev/mage-ai/mage_ai/tests/api/endpoints/test_blocks.py", line 154, in __assert_after_create_yaml
    self.assertEqual({
AssertionError: {'dbt[56 chars]h': 'dbts/dbt_yaml.yaml', 'project_path': 'dbt/test_project'}} != {'dbt[56 chars]h': 'BlockType.DBTs/dbt_yaml.yaml', 'project_p[21 chars]ct'}}
  {'dbt_project_name': 'dbt/test_project',
-  'file_source': {'path': 'dbts/dbt_yaml.yaml',
?                           ^^^

+  'file_source': {'path': 'BlockType.DBTs/dbt_yaml.yaml',
?                           ^^^^^^^^^^^^^

                   'project_path': 'dbt/test_project'}}

----------------------------------------------------------------------
Ran 27 tests in 2.061s

FAILED (failures=1)

How Has This Been Tested?

  • Tested with a local development environment.

Checklist

  • The PR is tagged with proper labels (bug, enhancement, feature, documentation)
  • I have performed a self-review of my own code
  • I have added unit tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

cc:

@wangxiaoyou1993

@csharplus csharplus self-assigned this Sep 7, 2024
@csharplus csharplus changed the title Use string concatenation for Enum to resolve unit test failures with Python 3.11+ Introduce StrEnum and IntEnum classes to resolve unit test failures with Python 3.11+ Sep 8, 2024
@@ -1,7 +1,14 @@
from enum import Enum
try:
Copy link
Member

@wangxiaoyou1993 wangxiaoyou1993 Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the code can be duplicated across multiple files, i would suggest putting it in the shared/enum.py and import the StrEnum from shared.enum

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, made the suggested change.

@csharplus csharplus merged commit dfddfae into master Sep 9, 2024
12 checks passed
@csharplus csharplus deleted the csharplus_update_enum_string_concat branch September 9, 2024 01:05
@wangxiaoyou1993 wangxiaoyou1993 linked an issue Sep 9, 2024 that may be closed by this pull request
@wangxiaoyou1993 wangxiaoyou1993 mentioned this pull request Sep 17, 2024
6 tasks
wangxiaoyou1993 added a commit that referenced this pull request Sep 18, 2024
# Description
<!-- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.
List any dependencies that are required for this change.
-->
Bump version to 0.9.74

<!-- Release notes generated using configuration in .github/release.yml
at master -->

## What's Changed
### 🎉 Exciting New Features
* Initialize google cloud storage source by @TalaatHasanin in
#5334
* Add support to scheduler name on k8s executor by @messerzen in
#5412
* Airtable Integration by @TalaatHasanin in
#5404
* Add trim reformat action to transformer block by @cristopheridlc in
#5321
* Enable polars dataframe by @TalaatHasanin in
#5348

### 🐛 Bug Fixes
* [jk] Update condition for cookie secure property by @johnson-mage in
#5327
* [xy] Fix NoneType in trigger settings. by @wangxiaoyou1993 in
#5329
* [xy] Fix dbt block delete request with nginx. by @wangxiaoyou1993 in
#5332
* [xy] Fix API for file versions. by @wangxiaoyou1993 in
#5338
* [xy] Fix schema creation when schema name is wrapped with double
quotes. by @wangxiaoyou1993 in
#5366
* [jk] Update test ENV value by @johnson-mage in
#5372
* [xh] Add retry logic and throw if open AI API returns error by
@matrixstone in #5375
* [jk] Fix typo for custom frequency in trigger review by @johnson-mage
in #5392
* [td] Fix Git syncs API error returning sync_on_executor_start by
@tommydangerous in #5388
* #5417 Fix bug: Can't use git with Bitbucket by @kennynguyeenx in
#5418
* Dynamic block fixes
* [td] Fix index used in dynamic block by @tommydangerous in
#5373
* [xy] Fix the condition of checking dynamic upstreams completed
2f2eeca
* [xy] Some updates and fixes for dynamic blocks
7eba140
* [hw] Fix a missing import issue with data types in a template for Data
Exporters by @csharplus in #5377
* SASL_SSL kafka Host Name Validation by @sujiplr in
#5380

### 💅 Enhancements & Polish
* [xy] Reduce CPU usage in scheduler. by @wangxiaoyou1993 in
#5331
* [xy] Pass main pod labels to workspaces. by @wangxiaoyou1993 in
#5344
* enhancement: bump duckdb to 1.0.0 by @matsonj in
#5358
* Pass all SSL settings through for SASL_SSL by @csharplus in
#5381
* Update unit tests to use the methods compatible with Python 3.12 by
@csharplus in #5398
* Introduce StrEnum and IntEnum classes to resolve unit test failures
with Python 3.11+ by @csharplus in
#5397
* Add NATS credentials file authentication by @ddecaro11 in
#5410
* Update a few unit tests that failed on Python 3.12 by @csharplus in
#5420
* Fix kafka module related unit test failure issues in Python 3.12 by
@csharplus in #5424
* Add trigger name in kwargs
81e4f91
* Expose column name related config to postgres sink config
c40af5f
* [xh] Add ENV variables to turn on/off AI API by @matrixstone in
#5394

### Other Changes
* Update amazon-s3.mdx by @Ayumi08 in
#5337
* Fix spelling in compute-resource.mdx by @samacciu23 in
#5356
* Update logger.py by @vffv2000 in
#5383
* [hw] Update the user guide for Kafka streaming with latest changes
based on testing by @csharplus in
#5378
* Update the development document to resolve one issue encountered by
@csharplus in #5396
* Fixing spelling error by @benjaminhawn in
#5407

## New Contributors
* @cristopheridlc made their first contribution in
#5321
* @TalaatHasanin made their first contribution in
#5348
* @samacciu23 made their first contribution in
#5356
* @matsonj made their first contribution in
#5358
* @vffv2000 made their first contribution in
#5383
* @benjaminhawn made their first contribution in
#5407
* @ddecaro11 made their first contribution in
#5410
* @Jaykold made their first contribution in
#5340
* @kennynguyeenx made their first contribution in
#5418
* @messerzen made their first contribution in
#5412

**Full Changelog**:
0.9.73...0.9.74

# How Has This Been Tested?
<!-- Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
-->

- [x] Common tests


# Checklist
- [x] The PR is tagged with proper labels (bug, enhancement, feature,
documentation)
- [x] I have performed a self-review of my own code
- [ ] I have added unit tests that prove my fix is effective or that my
feature works
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation

cc:
<!-- Optionally mention someone to let them know about this pull request
-->
@csharplus csharplus changed the title Introduce StrEnum and IntEnum classes to resolve unit test failures with Python 3.11+ [hw] Introduce StrEnum and IntEnum classes to resolve unit test failures with Python 3.11+ Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade the Python version
2 participants