Skip to content

Commit

Permalink
Add support for Python 3.11
Browse files Browse the repository at this point in the history
Changes made:

* Replace usage of Enum plus str mixin with StrEnum, as per
  python/cpython#100458

* Sync "typing_extensions" version between requirements.txt and pyproject.toml
  • Loading branch information
matrixstone authored and lqc committed Apr 25, 2024
1 parent 295264d commit 06fba20
Showing 82 changed files with 271 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
needs: check-code-quality
steps:
- uses: actions/checkout@v3
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-bookworm
FROM python:3.11-bookworm
LABEL description="Deploy Mage on ECS"
ARG FEATURE_BRANCH
USER root
2 changes: 1 addition & 1 deletion docs/contributing/charts/how-to-add.mdx
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ sidebarTitle: "Charts"
Add a new type in [`mage_ai/data_preparation/models/widget/constants.py`](https://github.com/mage-ai/mage-ai/blob/master/mage_ai/data_preparation/models/widget/constants.py):

```python
class ChartType(str, Enum):
class ChartType(StrEnum):
# ...
PIE_CHART = 'pie_chart'
```
4 changes: 2 additions & 2 deletions mage_ai/ai/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum


class LLMUseCase(str, Enum):
class LLMUseCase(StrEnum):
GENERATE_DOC_FOR_BLOCK = 'generate_doc_for_block'
GENERATE_DOC_FOR_PIPELINE = 'generate_doc_for_pipeline'
GENERATE_BLOCK_WITH_DESCRIPTION = 'generate_block_with_description'
9 changes: 4 additions & 5 deletions mage_ai/api/constants.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from enum import Enum

from mage_ai.api.operations.constants import OperationType
from mage_ai.orchestration.db.models.oauth import Permission
from mage_ai.shared.enum import StrEnum


class AttributeOperationType(str, Enum):
class AttributeOperationType(StrEnum):
QUERY = 'query'
READ = 'read'
WRITE = 'write'


class AttributeType(str, Enum):
class AttributeType(StrEnum):
ALL = '__*MAGE*__'


class AuthorizeStatusType(str, Enum):
class AuthorizeStatusType(StrEnum):
ALL = 'all'
FAILED = 'failed'
SUCCEEDED = 'succeeded'
4 changes: 2 additions & 2 deletions mage_ai/api/oauth_scope.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum


class OauthScope():
@@ -18,7 +18,7 @@ class OauthScope():
TOKEN_SCOPES = []


class OauthScopeType(str, Enum):
class OauthScopeType(StrEnum):
CLIENT_ALL = 'all'
CLIENT_INTERNAL = 'internal'
CLIENT_PRIVATE = 'private'
4 changes: 2 additions & 2 deletions mage_ai/api/operations/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum

ALL = 'all'
CREATE = 'create'
@@ -20,7 +20,7 @@
COOKIE_PREFIX = '__COOKIE__'


class OperationType(str, Enum):
class OperationType(StrEnum):
ALL = ALL
CREATE = CREATE
DELETE = DELETE
4 changes: 2 additions & 2 deletions mage_ai/authentication/oauth/constants.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from enum import Enum
from typing import Optional

from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import GHE_HOSTNAME
from mage_ai.shared.enum import StrEnum

ACTIVE_DIRECTORY_CLIENT_ID = '51aec820-9d49-40a9-b046-17c1f28f620d'

GITHUB_CLIENT_ID = '8577f13ddc81e2848b07'
GITHUB_STATE = '1337'


class ProviderName(str, Enum):
class ProviderName(StrEnum):
ACTIVE_DIRECTORY = 'active_directory'
AZURE_DEVOPS = 'azure_devops'
BITBUCKET = 'bitbucket'
4 changes: 2 additions & 2 deletions mage_ai/authentication/operation_history/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum

MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT = '.operation_history'
MAGE_OPERATION_HISTORY_DIRECTORY_ENVIRONMENT_VARIABLE_NAME = 'MAGE_OPERATION_HISTORY_DIRECTORY'


class ResourceType(str, Enum):
class ResourceType(StrEnum):
PIPELINE = 'pipeline'
11 changes: 5 additions & 6 deletions mage_ai/authentication/permissions/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from enum import Enum

from mage_ai.api.operations.constants import OperationType
from mage_ai.data_preparation.models.constants import BlockType, PipelineType
from mage_ai.shared.enum import IntEnum, StrEnum


class EntityName(str, Enum):
class EntityName(StrEnum):
ALL = 'ALL'
ALL_EXCEPT_RESERVED = 'ALL_EXCEPT_RESERVED'
AutocompleteItem = 'AutocompleteItem'
@@ -103,7 +102,7 @@ class EntityName(str, Enum):
]


class BaseEntityType(str, Enum):
class BaseEntityType(StrEnum):
pass


@@ -131,7 +130,7 @@ class PipelineEntityType(BaseEntityType):
STREAMING = PipelineType.STREAMING.value


class PermissionAccess(int, Enum):
class PermissionAccess(IntEnum):
OWNER = 1
ADMIN = 2
# Editor: list, detail, create, update, delete
@@ -171,7 +170,7 @@ class PermissionAccess(int, Enum):
DISABLE_UNLESS_CONDITIONS = 1073741824


class PermissionCondition(str, Enum):
class PermissionCondition(StrEnum):
HAS_NOTEBOOK_EDIT_ACCESS = 'HAS_NOTEBOOK_EDIT_ACCESS'
HAS_PIPELINE_EDIT_ACCESS = 'HAS_PIPELINE_EDIT_ACCESS'
USER_OWNS_ENTITY = 'USER_OWNS_ENTITY'
4 changes: 2 additions & 2 deletions mage_ai/cache/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum

CACHE_KEY_BLOCKS_TO_PIPELINE_MAPPING = 'blocks_to_pipeline_mapping'
CACHE_KEY_BLOCK_ACTION_OBJECTS_MAPPING = 'block_action_objects_mapping'
@@ -11,5 +11,5 @@
MAGE_CACHE_DIRECTORY_ENVIRONMENT_VARIABLE_NAME = 'MAGE_CACHE_DIRECTORY'


class CacheItemType(str, Enum):
class CacheItemType(StrEnum):
DBT = 'dbt'
5 changes: 2 additions & 3 deletions mage_ai/cache/dbt/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from enum import Enum

from mage_ai.data_preparation.models.constants import (
BLOCK_TYPE_DIRECTORY_NAME,
PIPELINES_FOLDER,
BlockType,
)
from mage_ai.shared.enum import StrEnum
from mage_ai.shared.hash import merge_dict

IGNORE_DIRECTORY_NAMES = merge_dict(
@@ -19,7 +18,7 @@
PROJECT_FILENAMES = [PROJECT_FILENAME, 'dbt_project.yaml']


class FileType(str, Enum):
class FileType(StrEnum):
MODEL = 'model'
PROFILES = 'profiles'
PROJECT = 'project'
4 changes: 2 additions & 2 deletions mage_ai/cluster_manager/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum

# ECS environment variables
ECS_CLUSTER_NAME = 'ECS_CLUSTER_NAME'
@@ -29,7 +29,7 @@
NODE_PORT_SERVICE_TYPE = 'NodePort'


class ClusterType(str, Enum):
class ClusterType(StrEnum):
EMR = 'emr'
ECS = 'ecs'
CLOUD_RUN = 'cloud_run'
26 changes: 13 additions & 13 deletions mage_ai/command_center/constants.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum

SETTINGS_FILENAME = '.command_center.yaml'


class ItemTagEnum(str, Enum):
class ItemTagEnum(StrEnum):
PINNED = 'pinned'
RECENT = 'recent'


class ItemType(str, Enum):
class ItemType(StrEnum):
ACTION = 'action' # Cast spell
CREATE = 'create' # Conjure
DELETE = 'delete'
@@ -22,7 +22,7 @@ class ItemType(str, Enum):
UPDATE = 'update'


class ObjectType(str, Enum):
class ObjectType(StrEnum):
APPLICATION = 'application'
APPLICATION_EXPANSION = 'application_expansion'
AUTHENTICATION = 'authentication'
@@ -42,11 +42,11 @@ class ObjectType(str, Enum):
VERSION_CONTROL_FILE = 'version_control_file'


class ModeType(str, Enum):
class ModeType(StrEnum):
VERSION_CONTROL = 'version_control'


class FileExtension(str, Enum):
class FileExtension(StrEnum):
CSV = 'csv'
JSON = 'json'
MD = 'md'
@@ -59,7 +59,7 @@ class FileExtension(str, Enum):
YML = 'yml'


class ButtonActionType(str, Enum):
class ButtonActionType(StrEnum):
ADD_APPLICATION = 'add_application'
CLOSE_APPLICATION = 'close_application' # Go back out of the current application.
CLOSE_COMMAND_CENTER = 'close_command_center'
@@ -70,7 +70,7 @@ class ButtonActionType(str, Enum):
SELECT_ITEM_FROM_REQUEST = 'select_item_from_request'


class InteractionType(str, Enum):
class InteractionType(StrEnum):
CLICK = 'click'
CLOSE_APPLICATION = ButtonActionType.CLOSE_APPLICATION.value
CLOSE_COMMAND_CENTER = ButtonActionType.CLOSE_COMMAND_CENTER.value
@@ -81,30 +81,30 @@ class InteractionType(str, Enum):
SELECT_ITEM = 'select_item'


class ApplicationType(str, Enum):
class ApplicationType(StrEnum):
DETAIL = 'detail'
DETAIL_LIST = 'detail_list'
EXPANSION = 'expansion'
FORM = 'form'
LIST = 'list'


class ValidationType(str, Enum):
class ValidationType(StrEnum):
CONFIRMATION = 'confirmation'
CUSTOM_VALIDATION_PARSERS = 'custom_validation_parsers'


class RenderLocationType(str, Enum):
class RenderLocationType(StrEnum):
ITEMS_CONTAINER_AFTER = 'items_container_after'


class ApplicationExpansionUUID(str, Enum):
class ApplicationExpansionUUID(StrEnum):
ArcaneLibrary = 'ArcaneLibrary'
PortalTerminal = 'PortalTerminal'
VersionControlFileDiffs = 'VersionControlFileDiffs'


class ApplicationExpansionStatus(str, Enum):
class ApplicationExpansionStatus(StrEnum):
ACTIVE = 'ACTIVE'
CLOSED = 'CLOSED'
INACTIVE = 'INACTIVE'
4 changes: 2 additions & 2 deletions mage_ai/data_cleaner/column_types/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum


class ColumnType(str, Enum):
class ColumnType(StrEnum):
CATEGORY = 'category'
CATEGORY_HIGH_CARDINALITY = 'category_high_cardinality'
DATETIME = 'datetime'
19 changes: 10 additions & 9 deletions mage_ai/data_cleaner/transformer_actions/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from mage_ai.data_cleaner.column_types.constants import ColumnType
from enum import Enum
import pandas as pd
import numpy as np
import re

import numpy as np
import pandas as pd

from mage_ai.data_cleaner.column_types.constants import ColumnType
from mage_ai.shared.enum import StrEnum

CONSTANT_IMPUTATION_DEFAULTS = {
ColumnType.CATEGORY: 'missing',
@@ -34,7 +35,7 @@
}


class ActionType(str, Enum):
class ActionType(StrEnum):
ADD = 'add'
AVERAGE = 'average'
CLEAN_COLUMN_NAME = 'clean_column_name'
@@ -73,18 +74,18 @@ class ActionType(str, Enum):
STANDARDIZE = 'standardize'


class Axis(str, Enum):
class Axis(StrEnum):
COLUMN = 'column'
ROW = 'row'


class VariableType(str, Enum):
class VariableType(StrEnum):
FEATURE = 'feature'
FEATURE_SET = 'feature_set'
FEATURE_SET_VERSION = 'feature_set_version'


class Operator(str, Enum):
class Operator(StrEnum):
CONTAINS = 'contains'
NOT_CONTAINS = 'not contains'
EQUALS = '=='
@@ -95,7 +96,7 @@ class Operator(str, Enum):
LESS_THAN_OR_EQUALS = '<='


class ImputationStrategy(str, Enum):
class ImputationStrategy(StrEnum):
AVERAGE = 'average'
COLUMN = 'column'
CONSTANT = 'constant'
4 changes: 2 additions & 2 deletions mage_ai/data_preparation/logging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from dataclasses import dataclass, field
from enum import Enum
from typing import Dict

from mage_ai.shared.config import BaseConfig
from mage_ai.shared.enum import StrEnum
from mage_ai.shared.logger import LoggingLevel


class LoggerType(str, Enum):
class LoggerType(StrEnum):
DEFAULT = 'file'
S3 = 's3'
GCS = 'gcs'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from mage_ai.shared.enum import StrEnum

BLOCK_CATALOG_FILENAME = 'catalog.json'
REPLICATION_METHOD_INCREMENTAL = 'INCREMENTAL'
@@ -81,6 +81,6 @@
VARIABLE_BOOKMARK_VALUES_KEY = '__bookmark_values__'


class IngestMode(str, Enum):
class IngestMode(StrEnum):
DISK = 'disk'
MEMORY = 'memory'
Loading

0 comments on commit 06fba20

Please sign in to comment.