Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230526-153738.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: fix StopIteration error when publication for project not found
time: 2023-05-26T15:37:38.952939-04:00
custom:
Author: michelleark
Issue: "7711"
2 changes: 0 additions & 2 deletions core/dbt/contracts/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class PublicationMandatory:
@dataclass
@schema_version("publication", 1)
class PublicationArtifact(ArtifactMixin, PublicationMandatory):
"""This represents the <project_name>_publication.json artifact"""

public_models: Dict[str, PublicModel] = field(default_factory=dict)
metadata: PublicationMetadata = field(default_factory=PublicationMetadata)
# list of project name strings
Expand Down
12 changes: 6 additions & 6 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ def __init__(
self.root_project: RuntimeConfig = root_project
self.all_projects: Mapping[str, Project] = all_projects
self.file_diff = file_diff
self.publications = publications
self.publications: Mapping[str, PublicationArtifact] = (
{publication.project_name: publication for publication in publications}
if publications
else {}
)
self.manifest: Manifest = Manifest()
self.new_manifest = self.manifest
self.manifest.metadata = root_project.get_metadata()
Expand Down Expand Up @@ -841,11 +845,7 @@ def build_public_nodes(self) -> bool:

def load_new_public_nodes(self):
for project in self.manifest.project_dependencies.projects:
publication = (
next(p for p in self.publications if p.project_name == project.name)
if self.publications
else None
)
publication = self.publications.get(project.name)
if publication:
publication_config = PublicationConfig.from_publication(publication)
self.manifest.publications[project.name] = publication_config
Expand Down
6 changes: 5 additions & 1 deletion tests/functional/multi_project/test_publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ def models(self):
def test_pub_artifacts(self, project):
write_file(dependencies_yml, "dependencies.yml")

# Dependencies lists "marketing" project, but no publication file found
# Dependencies lists "marketing" project, but no publications provided
with pytest.raises(PublicationConfigNotFound):
run_dbt(["parse"])

# Dependencies lists "marketing" project, but no "marketing" publication provided
with pytest.raises(PublicationConfigNotFound):
run_dbt(["parse"], publications=[PublicationArtifact(project_name="not_marketing")])

# Provide publication and try again
m_pub_json = marketing_pub_json.replace("test_schema", project.test_schema)
publications = [PublicationArtifact.from_dict(json.loads(m_pub_json))]
Expand Down