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

[Requirements] Bump fastapi and uvicorn #2629

Merged
merged 12 commits into from Jan 1, 2023
2 changes: 1 addition & 1 deletion dockerfiles/mlrun-api/requirements.txt
@@ -1,4 +1,4 @@
uvicorn~=0.17.0
uvicorn~=0.20.0
dask-kubernetes~=0.11.0
apscheduler~=3.6
sqlite3-to-mysql~=1.4
Expand Down
1 change: 0 additions & 1 deletion mlrun/api/main.py
Expand Up @@ -361,7 +361,6 @@ def main():
"mlrun.api.main:app",
host="0.0.0.0",
port=config.httpdb.port,
debug=config.httpdb.debug,
access_log=False,
timeout_keep_alive=config.httpdb.http_connection_timeout_keep_alive,
)
Expand Down
7 changes: 4 additions & 3 deletions mlrun/api/schemas/artifact.py
Expand Up @@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
import typing

import pydantic

from mlrun.api.utils.helpers import StrEnum

class ArtifactCategories(str, enum.Enum):

class ArtifactCategories(StrEnum):
model = "model"
dataset = "dataset"
other = "other"
Expand Down Expand Up @@ -55,6 +56,6 @@ class ArtifactIdentifier(pydantic.BaseModel):
# hash: typing.Optional[str]


class ArtifactsFormat(str, enum.Enum):
class ArtifactsFormat(StrEnum):
full = "full"
legacy = "legacy"
9 changes: 5 additions & 4 deletions mlrun/api/schemas/auth.py
Expand Up @@ -12,22 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
import typing

import pydantic
from nuclio.auth import AuthInfo as NuclioAuthInfo
from nuclio.auth import AuthKinds as NuclioAuthKinds

from mlrun.api.utils.helpers import StrEnum

class ProjectsRole(str, enum.Enum):

class ProjectsRole(StrEnum):
iguazio = "iguazio"
mlrun = "mlrun"
nuclio = "nuclio"
nop = "nop"


class AuthorizationAction(str, enum.Enum):
class AuthorizationAction(StrEnum):
read = "read"
create = "create"
update = "update"
Expand All @@ -38,7 +39,7 @@ class AuthorizationAction(str, enum.Enum):
store = "store"


class AuthorizationResourceTypes(str, enum.Enum):
class AuthorizationResourceTypes(StrEnum):
project = "project"
log = "log"
runtime_resource = "runtime-resource"
Expand Down
5 changes: 3 additions & 2 deletions mlrun/api/schemas/background_task.py
Expand Up @@ -13,15 +13,16 @@
# limitations under the License.
#
import datetime
import enum
import typing

import pydantic

from mlrun.api.utils.helpers import StrEnum

from .object import ObjectKind


class BackgroundTaskState(str, enum.Enum):
class BackgroundTaskState(StrEnum):
succeeded = "succeeded"
failed = "failed"
running = "running"
Expand Down
5 changes: 3 additions & 2 deletions mlrun/api/schemas/clusterization_spec.py
Expand Up @@ -12,17 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
import typing

import pydantic

from mlrun.api.utils.helpers import StrEnum


class ClusterizationSpec(pydantic.BaseModel):
chief_api_state: typing.Optional[str]
chief_version: typing.Optional[str]


class WaitForChiefToReachOnlineStateFeatureFlag(str, enum.Enum):
class WaitForChiefToReachOnlineStateFeatureFlag(StrEnum):
enabled = "enabled"
disabled = "disabled"
15 changes: 7 additions & 8 deletions mlrun/api/schemas/constants.py
Expand Up @@ -12,14 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from enum import Enum

import mergedeep

import mlrun.errors
from mlrun.api.utils.helpers import StrEnum


class PatchMode(str, Enum):
class PatchMode(StrEnum):
replace = "replace"
additive = "additive"

Expand All @@ -34,7 +33,7 @@ def to_mergedeep_strategy(self) -> mergedeep.Strategy:
)


class DeletionStrategy(str, Enum):
class DeletionStrategy(StrEnum):
restrict = "restrict"
restricted = "restricted"
cascade = "cascade"
Expand Down Expand Up @@ -94,7 +93,7 @@ class HeaderNames:
client_version = f"{headers_prefix}client-version"


class FeatureStorePartitionByField(str, Enum):
class FeatureStorePartitionByField(StrEnum):
name = "name" # Supported for feature-store objects

def to_partition_by_db_field(self, db_cls):
Expand All @@ -106,7 +105,7 @@ def to_partition_by_db_field(self, db_cls):
)


class RunPartitionByField(str, Enum):
class RunPartitionByField(StrEnum):
name = "name" # Supported for runs objects

def to_partition_by_db_field(self, db_cls):
Expand All @@ -118,7 +117,7 @@ def to_partition_by_db_field(self, db_cls):
)


class SortField(str, Enum):
class SortField(StrEnum):
created = "created"
updated = "updated"

Expand All @@ -136,7 +135,7 @@ def to_db_field(self, db_cls):
)


class OrderType(str, Enum):
class OrderType(StrEnum):
asc = "asc"
desc = "desc"

Expand Down
11 changes: 6 additions & 5 deletions mlrun/api/schemas/frontend_spec.py
Expand Up @@ -12,32 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
import typing

import pydantic

from mlrun.api.utils.helpers import StrEnum

from .k8s import Resources


class ProjectMembershipFeatureFlag(str, enum.Enum):
class ProjectMembershipFeatureFlag(StrEnum):
enabled = "enabled"
disabled = "disabled"


class PreemptionNodesFeatureFlag(str, enum.Enum):
class PreemptionNodesFeatureFlag(StrEnum):
enabled = "enabled"
disabled = "disabled"


class AuthenticationFeatureFlag(str, enum.Enum):
class AuthenticationFeatureFlag(StrEnum):
none = "none"
basic = "basic"
bearer = "bearer"
iguazio = "iguazio"


class NuclioStreamsFeatureFlag(str, enum.Enum):
class NuclioStreamsFeatureFlag(StrEnum):
enabled = "enabled"
disabled = "disabled"

Expand Down
9 changes: 5 additions & 4 deletions mlrun/api/schemas/function.py
Expand Up @@ -13,12 +13,13 @@
# limitations under the License.
#
import typing
from enum import Enum

import pydantic

from mlrun.api.utils.helpers import StrEnum

# Ideally we would want this to be class FunctionState(str, enum.Enum) which is the "FastAPI-compatible" way of creating

# Ideally we would want this to be class FunctionState(StrEnum) which is the "FastAPI-compatible" way of creating
# schemas
# But, when we save a function to the DB, we pickle the body, which saves the state as an instance of this class (and
# not just a string), then if for some reason we downgrade to 0.6.4, before we had this class, we fail reading (pickle
Expand All @@ -45,7 +46,7 @@ class FunctionState:
build = "build"


class PreemptionModes(str, Enum):
class PreemptionModes(StrEnum):
# makes function pods be able to run on preemptible nodes
allow = "allow"
# makes the function pods run on preemptible nodes only
Expand All @@ -58,7 +59,7 @@ class PreemptionModes(str, Enum):

# used when running in Iguazio (otherwise use disabled mode)
# populates mlrun.mlconf.function.spec.security_context.enrichment_mode
class SecurityContextEnrichmentModes(str, Enum):
class SecurityContextEnrichmentModes(StrEnum):
# always use the user id of the user that triggered the 1st run / created the function
# NOTE: this mode is incomplete and not fully supported yet
retain = "retain"
Expand Down
4 changes: 2 additions & 2 deletions mlrun/api/schemas/http.py
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
from mlrun.api.utils.helpers import StrEnum


class HTTPSessionRetryMode(str, enum.Enum):
class HTTPSessionRetryMode(StrEnum):
enabled = "enabled"
disabled = "disabled"
5 changes: 3 additions & 2 deletions mlrun/api/schemas/k8s.py
Expand Up @@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
import typing

import pydantic

from mlrun.api.utils.helpers import StrEnum


class ResourceSpec(pydantic.BaseModel):
cpu: typing.Optional[str]
Expand All @@ -29,7 +30,7 @@ class Resources(pydantic.BaseModel):
limits: ResourceSpec = ResourceSpec()


class NodeSelectorOperator(str, enum.Enum):
class NodeSelectorOperator(StrEnum):
"""
A node selector operator is the set of operators that can be used in a node selector requirement
https://github.com/kubernetes/api/blob/b754a94214be15ffc8d648f9fe6481857f1fc2fe/core/v1/types.go#L2765
Expand Down
4 changes: 2 additions & 2 deletions mlrun/api/schemas/marketplace.py
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
from datetime import datetime, timezone
from typing import List, Optional

from pydantic import BaseModel, Extra, Field

import mlrun.errors
from mlrun.api.schemas.object import ObjectKind, ObjectSpec, ObjectStatus
from mlrun.api.utils.helpers import StrEnum
from mlrun.config import config


Expand All @@ -37,7 +37,7 @@ class Config:


# Currently only functions are supported. Will add more in the future.
class MarketplaceSourceType(str, enum.Enum):
class MarketplaceSourceType(StrEnum):
functions = "functions"


Expand Down
4 changes: 2 additions & 2 deletions mlrun/api/schemas/model_endpoints.py
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
from typing import Any, Dict, List, Optional, Tuple, Union

from pydantic import BaseModel, Field
from pydantic.main import Extra

from mlrun.api.schemas.object import ObjectKind, ObjectSpec, ObjectStatus
from mlrun.api.utils.helpers import StrEnum
from mlrun.utils.model_monitoring import EndpointType, create_model_endpoint_id


Expand All @@ -36,7 +36,7 @@ class Config:
extra = Extra.allow


class ModelMonitoringMode(str, enum.Enum):
class ModelMonitoringMode(StrEnum):
enabled = "enabled"
disabled = "disabled"

Expand Down
5 changes: 3 additions & 2 deletions mlrun/api/schemas/object.py
Expand Up @@ -13,11 +13,12 @@
# limitations under the License.
#
from datetime import datetime
from enum import Enum
from typing import List, Optional

from pydantic import BaseModel, Extra

from mlrun.api.utils.helpers import StrEnum


class ObjectMetadata(BaseModel):
name: str
Expand Down Expand Up @@ -68,7 +69,7 @@ class Config:
orm_mode = True


class ObjectKind(str, Enum):
class ObjectKind(StrEnum):
project = "project"
feature_set = "FeatureSet"
background_task = "BackgroundTask"
Expand Down
5 changes: 3 additions & 2 deletions mlrun/api/schemas/pipeline.py
Expand Up @@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import enum
import typing

import pydantic

from mlrun.api.utils.helpers import StrEnum

class PipelinesFormat(str, enum.Enum):

class PipelinesFormat(StrEnum):
full = "full"
metadata_only = "metadata_only"
summary = "summary"
Expand Down