Skip to content

Commit

Permalink
Kill Uniqueness Opt-out (dagster-io#1193)
Browse files Browse the repository at this point in the history
No longer has external users.
  • Loading branch information
schrockn authored Apr 10, 2019
1 parent 71e6fb5 commit eefe3ab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pylint:
done;
set +e;

update_doc_snapshot:
pytest python_modules/dagster/docs --snapshot-update

black:
black python_modules --line-length 100 -S --fast --exclude "build/|buck-out/|dist/|_build/|\.eggs/|\.git/|\.hg/|\.mypy_cache/|\.nox/|\.tox/|\.venv/|python_modules/dagster/dagster/tutorials/|snapshots/|__scaffold\.py" -N
black python_modules/dagster/dagster/tutorials examples --line-length 79 -S --fast -N
Expand Down
27 changes: 9 additions & 18 deletions python_modules/dagster/dagster/core/definitions/repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dagster import check
from dagster.core.errors import DagsterInvalidDefinitionError, DagsterInvariantViolationError
from dagster.core.errors import DagsterInvalidDefinitionError
from .pipeline import PipelineDefinition


Expand All @@ -20,7 +20,7 @@ class RepositoryDefinition(object):
'''

def __init__(self, name, pipeline_dict, enforce_uniqueness=True):
def __init__(self, name, pipeline_dict):
'''
Args:
name (str): Name of pipeline.
Expand All @@ -37,8 +37,6 @@ def __init__(self, name, pipeline_dict, enforce_uniqueness=True):

self._pipeline_cache = {}

self.enforce_uniqueness = enforce_uniqueness

def has_pipeline(self, name):
check.str_param(name, 'name')
return name in self.pipeline_dict
Expand Down Expand Up @@ -109,26 +107,19 @@ def _construct_solid_defs(self, pipelines):
if solid_def.name not in solid_defs:
solid_defs[solid_def.name] = solid_def
solid_to_pipeline[solid_def.name] = pipeline.name
elif self.enforce_uniqueness:
if not solid_defs[solid_def.name] is solid_def:
raise DagsterInvalidDefinitionError(
'Trying to add duplicate solid def {} in {}, Already saw in {}'.format(
solid_def.name, pipeline.name, solid_to_pipeline[solid_def.name]
)

if not solid_defs[solid_def.name] is solid_def:
raise DagsterInvalidDefinitionError(
'Trying to add duplicate solid def {} in {}, Already saw in {}'.format(
solid_def.name, pipeline.name, solid_to_pipeline[solid_def.name]
)
)

return solid_defs

def get_solid_def(self, name):
check.str_param(name, 'name')

if not self.enforce_uniqueness:
raise DagsterInvariantViolationError(
(
'In order for get_solid_def to have reliable semantics '
'you must construct the repo with ensure_uniqueness=True'
)
)

solid_defs = self._construct_solid_defs(self.get_all_pipelines())

if name not in solid_defs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from dagster import (
DagsterInvalidDefinitionError,
DagsterInvariantViolationError,
PipelineDefinition,
RepositoryDefinition,
SolidDefinition,
Expand Down Expand Up @@ -88,27 +87,3 @@ def noop2():

with pytest.raises(DagsterInvalidDefinitionError):
repo.get_all_pipelines()


def test_dupe_solid_repo_definition_unforced():
@lambda_solid(name='same')
def noop():
pass

@lambda_solid(name='same')
def noop2():
pass

repo = RepositoryDefinition(
'error_repo',
pipeline_dict={
'first': lambda: PipelineDefinition(name='first', solids=[noop]),
'second': lambda: PipelineDefinition(name='second', solids=[noop2]),
},
enforce_uniqueness=False,
)

assert repo.get_all_pipelines()

with pytest.raises(DagsterInvariantViolationError):
repo.get_solid_def('first')
Original file line number Diff line number Diff line change
Expand Up @@ -19947,7 +19947,7 @@ def dataframe_input_schema(config_value):

<dl class="class">
<dt id="dagster.RepositoryDefinition">
<em class="property">class </em><code class="descclassname">dagster.</code><code class="descname">RepositoryDefinition</code><span class="sig-paren">(</span><em>name</em>, <em>pipeline_dict</em>, <em>enforce_uniqueness=True</em><span class="sig-paren">)</span><a class="headerlink" href="#dagster.RepositoryDefinition" title="Permalink to this definition">¶</a></dt>
<em class="property">class </em><code class="descclassname">dagster.</code><code class="descname">RepositoryDefinition</code><span class="sig-paren">(</span><em>name</em>, <em>pipeline_dict</em><span class="sig-paren">)</span><a class="headerlink" href="#dagster.RepositoryDefinition" title="Permalink to this definition">¶</a></dt>
<dd><p>Define a repository that contains a collection of pipelines.</p>
<dl class="attribute">
<dt id="dagster.RepositoryDefinition.name">
Expand Down

0 comments on commit eefe3ab

Please sign in to comment.