Skip to content

Commit

Permalink
Remove @abstractproperty (#6867)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannkm committed Mar 2, 2022
1 parent e9834b4 commit 0ac9e1c
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from dagster.daemon import get_default_daemon_logger
from dagster.daemon.sensor import execute_sensor_iteration

from .graphql_context_test_suite import ( # get_dict_recon_repo,
GraphQLContextVariant,
make_graphql_context_test_suite,
)
from .graphql_context_test_suite import GraphQLContextVariant # get_dict_recon_repo,
from .graphql_context_test_suite import make_graphql_context_test_suite

INSTIGATION_QUERY = """
query JobQuery($instigationSelector: InstigationSelector!) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from typing import Any, Callable, Dict, Optional, Union

from dagster import Field, check
Expand All @@ -12,7 +12,8 @@


class ConfigurableDefinition(ABC):
@abstractproperty
@property
@abstractmethod
def config_schema(self) -> Optional[IDefinitionConfigSchema]:
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import abstractmethod, abstractproperty
from abc import abstractmethod
from typing import TYPE_CHECKING, Mapping, Sequence

from dagster import check
Expand Down Expand Up @@ -45,11 +45,13 @@ def __init__(
else list(map(lambda inp: inp.name, input_defs))
)

@abstractproperty
@property
@abstractmethod
def node_type_str(self):
raise NotImplementedError()

@abstractproperty
@property
@abstractmethod
def is_graph_job_op_node(self) -> bool:
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, FrozenSet, List, Optional

from dagster import check
Expand All @@ -25,7 +25,8 @@ def get_definition(self) -> "PipelineDefinition":
def subset_for_execution(self, solid_selection: List[str]) -> "IPipeline":
pass

@abstractproperty
@property
@abstractmethod
def solids_to_execute(self) -> Optional[FrozenSet[str]]:
pass

Expand Down
26 changes: 17 additions & 9 deletions python_modules/dagster/dagster/core/execution/context/compute.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from typing import Any, Dict, Iterator, List, Mapping, Optional

from dagster import check
Expand Down Expand Up @@ -36,35 +36,43 @@ def has_tag(self, key) -> bool:
def get_tag(self, key: str) -> Optional[str]:
"""Implement this method to get a logging tag."""

@abstractproperty
@property
@abstractmethod
def run_id(self) -> str:
"""The run id for the context."""

@abstractproperty
@property
@abstractmethod
def solid_def(self) -> SolidDefinition:
"""The solid definition corresponding to the execution step being executed."""

@abstractproperty
@property
@abstractmethod
def solid(self) -> Node:
"""The solid corresponding to the execution step being executed."""

@abstractproperty
@property
@abstractmethod
def pipeline_def(self) -> PipelineDefinition:
"""The pipeline being executed."""

@abstractproperty
@property
@abstractmethod
def pipeline_run(self) -> PipelineRun:
"""The PipelineRun object corresponding to the execution."""

@abstractproperty
@property
@abstractmethod
def resources(self) -> Any:
"""Resources available in the execution context."""

@abstractproperty
@property
@abstractmethod
def log(self) -> DagsterLogManager:
"""The log manager available in the execution context."""

@abstractproperty
@property
@abstractmethod
def solid_config(self) -> Any:
"""The parsed config specific to this solid."""

Expand Down
14 changes: 9 additions & 5 deletions python_modules/dagster/dagster/core/execution/context/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
so we have a different layer of objects that encode the explicit public API
in the user_context module
"""
from abc import ABC, abstractproperty
from abc import ABC, abstractmethod
from collections import defaultdict
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -67,7 +67,8 @@ class IPlanContext(ABC):
The information available via this interface is accessible to the system throughout a run.
"""

@abstractproperty
@property
@abstractmethod
def plan_data(self) -> "PlanData":
raise NotImplementedError()

Expand Down Expand Up @@ -111,7 +112,8 @@ def retry_mode(self) -> RetryMode:
def execution_plan(self):
return self.plan_data.execution_plan

@abstractproperty
@property
@abstractmethod
def output_capture(self) -> Optional[Dict[StepOutputHandle, Any]]:
raise NotImplementedError()

Expand Down Expand Up @@ -163,11 +165,13 @@ class ExecutionData(NamedTuple):
class IStepContext(IPlanContext):
"""Interface to represent data to be available during either step orchestration or execution."""

@abstractproperty
@property
@abstractmethod
def step(self) -> ExecutionStep:
raise NotImplementedError()

@abstractproperty
@property
@abstractmethod
def solid_handle(self) -> "NodeHandle":
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import sys
from abc import ABC, abstractproperty
from abc import ABC, abstractmethod
from contextlib import contextmanager
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -181,7 +181,8 @@ def __init__(
generator=event_generator, object_cls=self.context_type, require_object=raise_on_error
)

@abstractproperty
@property
@abstractmethod
def context_type(self) -> Type[TContextType]:
pass

Expand Down
8 changes: 5 additions & 3 deletions python_modules/dagster/dagster/core/execution/plan/inputs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hashlib
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, NamedTuple, Optional, Set, Union, cast

from dagster import check
Expand Down Expand Up @@ -102,11 +102,13 @@ def step_output_handle_dependencies(self) -> List[StepOutputHandle]:
def get_input_def(self, pipeline_def: PipelineDefinition) -> InputDefinition:
return pipeline_def.get_solid(self.solid_handle).input_def_named(self.input_name)

@abstractproperty
@property
@abstractmethod
def solid_handle(self) -> NodeHandle:
pass

@abstractproperty
@property
@abstractmethod
def input_name(self) -> str:
pass

Expand Down
9 changes: 5 additions & 4 deletions python_modules/dagster/dagster/core/executor/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import abc
from abc import abstractmethod, ABC

from dagster.core.execution.retries import RetryMode


class Executor(abc.ABC): # pylint: disable=no-init
@abc.abstractmethod
class Executor(ABC): # pylint: disable=no-init
@abstractmethod
def execute(self, plan_context, execution_plan):
"""
For the given context and execution plan, orchestrate a series of sub plan executions in a way that satisfies the whole plan being executed.
Expand All @@ -17,7 +17,8 @@ def execute(self, plan_context, execution_plan):
A stream of dagster events.
"""

@abc.abstractproperty
@property
@abstractmethod
def retries(self) -> RetryMode:
"""
Whether retries are enabled or disabled for this instance of the executor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import abc
from abc import abstractmethod, ABC
from typing import Dict, List, Optional

from dagster import DagsterEvent, DagsterInstance, check
Expand Down Expand Up @@ -44,19 +44,20 @@ def instance(self) -> DagsterInstance:
return self._instance


class StepHandler(abc.ABC): # pylint: disable=no-init
@abc.abstractproperty
class StepHandler(ABC): # pylint: disable=no-init
@property
@abstractmethod
def name(self) -> str:
pass

@abc.abstractmethod
@abstractmethod
def launch_step(self, step_handler_context: StepHandlerContext) -> List[DagsterEvent]:
pass

@abc.abstractmethod
@abstractmethod
def check_step_health(self, step_handler_context: StepHandlerContext) -> List[DagsterEvent]:
pass

@abc.abstractmethod
@abstractmethod
def terminate_step(self, step_handler_context: StepHandlerContext) -> List[DagsterEvent]:
pass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC, abstractproperty
from abc import ABC, abstractmethod

from dagster import check

Expand Down Expand Up @@ -33,11 +33,13 @@ def description(self):

# Snapshot things

@abstractproperty
@property
@abstractmethod
def computed_pipeline_snapshot_id(self):
pass

@abstractproperty
@property
@abstractmethod
def identifying_pipeline_snapshot_id(self):
pass

Expand Down
5 changes: 3 additions & 2 deletions python_modules/dagster/dagster/core/storage/event_log/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from datetime import datetime
from typing import (
Callable,
Expand Down Expand Up @@ -195,7 +195,8 @@ def watch(self, run_id: str, start_cursor: int, callback: Callable):
def end_watch(self, run_id: str, handler: Callable):
"""Call this method to stop watching."""

@abstractproperty
@property
@abstractmethod
def is_persistent(self) -> bool:
"""bool: Whether the storage is persistent."""

Expand Down
5 changes: 3 additions & 2 deletions python_modules/dagster/dagster/core/storage/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import shutil
import uuid
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from contextlib import contextmanager
from typing import BinaryIO, TextIO, Union

Expand Down Expand Up @@ -31,7 +31,8 @@ class FileHandle(ABC):
such as S3.
"""

@abstractproperty
@property
@abstractmethod
def path_desc(self) -> str:
"""A representation of the file path for display purposes only."""
raise NotImplementedError()
Expand Down
5 changes: 3 additions & 2 deletions python_modules/dagster/dagster/core/storage/output_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod

from dagster.core.definitions.definition_config_schema import (
convert_user_facing_definition_config_schema,
Expand All @@ -7,7 +7,8 @@


class IOutputManagerDefinition:
@abstractproperty
@property
@abstractmethod
def output_config_schema(self):
"""The schema for per-output configuration for outputs that are managed by this
manager"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import abstractmethod, abstractproperty
from abc import abstractmethod
from functools import update_wrapper

from dagster import check
Expand All @@ -12,7 +12,8 @@


class IInputManagerDefinition:
@abstractproperty
@property
@abstractmethod
def input_config_schema(self):
"""The schema for per-input configuration for inputs that are managed by this
input manager"""
Expand Down
8 changes: 5 additions & 3 deletions python_modules/dagster/dagster/core/workspace/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import threading
import time
import warnings
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from collections import OrderedDict
from contextlib import ExitStack
from typing import TYPE_CHECKING, Dict, List, Optional, Union, cast
Expand Down Expand Up @@ -343,7 +343,8 @@ def create_request_context(self, source=None) -> BaseWorkspaceRequestContext:
def version(self) -> str:
pass

@abstractproperty
@property
@abstractmethod
def location_state_events(self) -> "Subject":
pass

Expand All @@ -358,7 +359,8 @@ def shutdown_repository_location(self, name: str) -> None:
def reload_workspace(self) -> None:
pass

@abstractproperty
@property
@abstractmethod
def instance(self):
pass

Expand Down

0 comments on commit 0ac9e1c

Please sign in to comment.