Skip to content

Commit

Permalink
feat: added get_lineage method to neo4j proxy (#259)
Browse files Browse the repository at this point in the history
* added query to neo4j for small details needed to add to lineage

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* lint

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* lint

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* added return type

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* added get_lineage to base proxy

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* added method to app proxys

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* removed method

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* removed lineage item from base proxy import

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* lint

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* bumped amundsen common version to 0.7.0

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* moved import to sort

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* fixed imports

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>

* implemented PR feedback

Signed-off-by: Allison Suarez Miranda <asuarezmiranda@lyft.com>
  • Loading branch information
allisonsuarez authored Feb 24, 2021
1 parent 012f9ab commit b129cc7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions metadata_service/proxy/atlas_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Any, Dict, List, Optional, Tuple, Union

from amundsen_common.models.dashboard import DashboardSummary
from amundsen_common.models.lineage import Lineage
from amundsen_common.models.popular_table import PopularTable
from amundsen_common.models.table import (Column, ProgrammaticDescription,
Reader, ResourceReport, Stat, Table,
Expand Down Expand Up @@ -1068,3 +1069,7 @@ def get_resources_using_table(self, *,
id: str,
resource_type: ResourceType) -> Dict[str, List[DashboardSummary]]:
return {}

def get_lineage(self, *,
id: str, resource_type: ResourceType, direction: str, depth: int) -> Lineage:
pass
12 changes: 12 additions & 0 deletions metadata_service/proxy/base_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any, Dict, List, Optional, Union

from amundsen_common.models.dashboard import DashboardSummary
from amundsen_common.models.lineage import Lineage
from amundsen_common.models.popular_table import PopularTable
from amundsen_common.models.table import Table
from amundsen_common.models.user import User
Expand Down Expand Up @@ -154,3 +155,14 @@ def get_resources_using_table(self, *,
id: str,
resource_type: ResourceType) -> Dict[str, List[DashboardSummary]]:
pass

@abstractmethod
def get_lineage(self, *,
id: str, resource_type: ResourceType, direction: str, depth: int) -> Lineage:
"""
Method should be implemented to obtain lineage from whatever source is preferred internally
:param direction: if the request is for a list of upstream/downstream nodes or both
:param depth: the level of lineage requested (ex: 1 would mean only nodes directly connected
to the current id in whatever direction is specified)
"""
pass
5 changes: 5 additions & 0 deletions metadata_service/proxy/gremlin_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import gremlin_python
from amundsen_common.models.dashboard import DashboardSummary
from amundsen_common.models.lineage import Lineage
from amundsen_common.models.popular_table import PopularTable
from amundsen_common.models.table import (Application, Column,
ProgrammaticDescription, Reader,
Expand Down Expand Up @@ -1722,6 +1723,10 @@ def _get_edge_type_from_user_resource_rel_type(self, relation: UserResourceRel)

raise NotImplementedError(f"Don't know how to handle UserResourceRel={relation}")

def get_lineage(self, *,
id: str, resource_type: ResourceType, direction: str, depth: int) -> Lineage:
pass


class GenericGremlinProxy(AbstractGremlinProxy):
"""
Expand Down
6 changes: 6 additions & 0 deletions metadata_service/proxy/neo4j_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import neo4j
from amundsen_common.models.dashboard import DashboardSummary
from amundsen_common.models.lineage import Lineage
from amundsen_common.models.popular_table import PopularTable
from amundsen_common.models.table import Application
from amundsen_common.models.table import Badge as TableBadge
Expand Down Expand Up @@ -1406,3 +1407,8 @@ def get_resources_using_table(self, *,
for record in records:
results.append(DashboardSummary(**record))
return {'dashboards': results}

def get_lineage(self, *,
id: str,
resource_type: ResourceType, direction: str, depth: int) -> Lineage:
pass
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typing-extensions==3.7.4

# A common package that holds the models deifnition and schemas that are used
# accross different amundsen repositories.
amundsen-common>=0.5.3
amundsen-common>=0.7.0
amundsen-gremlin>=0.0.4

boto3==1.12.12
Expand Down

0 comments on commit b129cc7

Please sign in to comment.