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

feat: added lineage item and lineage entities #90

Merged
merged 6 commits into from
Feb 23, 2021
Merged
Changes from 5 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
37 changes: 37 additions & 0 deletions amundsen_common/models/lineage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright Contributors to the Amundsen project.
# SPDX-License-Identifier: Apache-2.0

from typing import Optional, List

from amundsen_common.models.table import Badge

import attr
from marshmallow_annotations.ext.attrs import AttrsSchema


@attr.s(auto_attribs=True, kw_only=True)
class LineageItem:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you share some examples on this class? e.g what are the badges and usage using here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added the actual Badge class for badge list. Not sure what you mean by what the usage is using here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can change usage to be even more general and make it something like sorting_metric or something like that, but usage seems like a natural way in which we would want to highlight more important upstream/downstream resources when you have lots of them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question is around how the metadata lineage entity connection will look like with badge and usage.

key: str # down/upstream table/col/task key
level: int # upstream/downstream distance from current resource
source: str # database this resource is from
badges: Optional[List[Badge]] = None
usage: Optional[int] = None # statistic to sort lineage items by


class LineageItemSchema(AttrsSchema):
target = LineageItem
register_as_scheme = True


@attr.s(auto_attribs=True, kw_only=True)
class Lineage:
key: str # current table/col/task key
direction: str # upstream/downstream/both
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we need direction and depth if we have lineage_entities_upstream and lineage_entities_downstream?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LineageItem seems to include level already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to persist the selection (upstream, downstream, both) send over in the request. Similarly depth might be needed because it tells you how many levels were requested for this response.

depth: int # how many levels up/down 0 == all
lineage_entities_upstream: List[LineageItem] # list of upstream entities
allisonsuarez marked this conversation as resolved.
Show resolved Hide resolved
lineage_entities_downstream: List[LineageItem] # list of downstream entities
allisonsuarez marked this conversation as resolved.
Show resolved Hide resolved


class LineageSchema(AttrsSchema):
target = Lineage
register_as_scheme = True