Skip to content

Commit

Permalink
metadataservice: add neptune proxy
Browse files Browse the repository at this point in the history
add a bunch of test only proxy endpoints to support roundtrip tests.
pin specific common version to reduce surprises.

Signed-off-by: Joshua Hoskins <[email protected]>
  • Loading branch information
friendtocephalopods committed Sep 25, 2020
1 parent 6a81b97 commit c239a1f
Show file tree
Hide file tree
Showing 19 changed files with 2,950 additions and 179 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ We have Swagger documentation setup with OpenApi 3.0.2. This documentation is ge

## Code structure
Please visit [Code Structure](docs/structure.md) to read how different modules are structured in Amundsen Metadata service.

## Roundtrip tests
Roundtrip tests are a new feature - by implementing the abstract_proxy_tests and some test setup endpoints in the base_proxy, you can validate your proxy code against the actual data store. These tests do not run by default, but can be run by passing the `--roundtrip` argument.
```bash
$ python -m pytest --roundtrip .
```
6 changes: 5 additions & 1 deletion metadata_service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import os
from typing import List, Dict, Optional, Set # noqa: F401
from metadata_service.entity.badge import Badge
from amundsen_gremlin.config import (
LocalGremlinConfig
)

# PROXY configuration keys
PROXY_HOST = 'PROXY_HOST'
Expand Down Expand Up @@ -77,7 +80,8 @@ class Config:
PROGRAMMATIC_DESCRIPTIONS_EXCLUDE_FILTERS = [] # type: list


class LocalConfig(Config):
# NB: If you're using the gremlin proxy, the appropriate GremlinConfig must be added to any other configs
class LocalConfig(LocalGremlinConfig, Config):
DEBUG = True
TESTING = False
LOG_LEVEL = 'DEBUG'
Expand Down
37 changes: 34 additions & 3 deletions metadata_service/proxy/atlas_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from amundsen_common.models.dashboard import DashboardSummary
from amundsen_common.models.popular_table import PopularTable
from amundsen_common.models.table import Column, Statistics, Table, Tag, User, Reader, \
from amundsen_common.models.table import Application, Column, Stat, Table, Tag, User, Reader, \
ProgrammaticDescription, ResourceReport
from amundsen_common.models.user import User as UserEntity
from atlasclient.client import Atlas
Expand Down Expand Up @@ -308,7 +308,7 @@ def _serialize_columns(self, *, entity: EntityUniqueAttribute) -> \
Union[List[Column], List]:
"""
Helper function to fetch the columns from entity and serialize them
using Column and Statistics model.
using Column and Stat model.
:param entity: EntityUniqueAttribute object,
along with relationshipAttributes
:return: A list of Column objects, if there are any columns available,
Expand Down Expand Up @@ -348,7 +348,7 @@ def _serialize_columns(self, *, entity: EntityUniqueAttribute) -> \
end_epoch = stats_attrs.get('end_epoch')

statistics.append(
Statistics(
Stat(
stat_type=stat_type,
stat_val=stat_val,
start_epoch=start_epoch,
Expand Down Expand Up @@ -997,3 +997,34 @@ def get_resources_using_table(self, *,
id: str,
resource_type: ResourceType) -> Dict[str, List[DashboardSummary]]:
return {}

def put_user(self, *, data: User) -> None:
pass

def post_users(self, *, data: List[User]) -> None:
pass

def put_app(self, *, data: Application) -> None:
pass

def post_apps(self, *, data: List[Application]) -> None:
pass

def put_table(self, *, table: Table) -> None:
pass

def post_tables(self, *, tables: List[Table]) -> None:
pass

def put_column(self, *, table_uri: str, column: Column) -> None:
pass

def put_programmatic_table_description(self, *, table_uri: str, description: ProgrammaticDescription) -> None:
pass

def put_programmatic_column_description(self, *, table_uri: str, column_name: str,
description: Description) -> None:
pass

def add_read_count(self, *, table_uri: str, user_id: str, read_count: int) -> None:
pass
47 changes: 43 additions & 4 deletions metadata_service/proxy/base_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Any, Dict, List, Union

from amundsen_common.models.popular_table import PopularTable
from amundsen_common.models.table import Table
from amundsen_common.models.user import User as UserEntity
from amundsen_common.models.table import Table, Application, Column, ProgrammaticDescription
from amundsen_common.models.user import User
from amundsen_common.models.dashboard import DashboardSummary

from metadata_service.entity.dashboard_detail import DashboardDetail as DashboardDetailEntity
Expand All @@ -22,11 +22,11 @@ class BaseProxy(metaclass=ABCMeta):
"""

@abstractmethod
def get_user(self, *, id: str) -> Union[UserEntity, None]:
def get_user(self, *, id: str) -> Union[User, None]:
pass

@abstractmethod
def get_users(self) -> List[UserEntity]:
def get_users(self) -> List[User]:
pass

@abstractmethod
Expand Down Expand Up @@ -151,3 +151,42 @@ def get_resources_using_table(self, *,
id: str,
resource_type: ResourceType) -> Dict[str, List[DashboardSummary]]:
pass

# NB: the following methods exist solely for testing in the roundtrip tests.
# These may not be suitably performant for handling large batches

@abstractmethod
def put_user(self, *, data: User) -> None:
pass

@abstractmethod
def post_users(self, *, data: List[User]) -> None:
pass

@abstractmethod
def put_app(self, *, data: Application) -> None:
pass

@abstractmethod
def post_apps(self, *, data: List[Application]) -> None:
pass

@abstractmethod
def put_table(self, *, table: Table) -> None:
pass

@abstractmethod
def post_tables(self, *, tables: List[Table]) -> None:
pass

@abstractmethod
def put_column(self, *, table_uri: str, column: Column) -> None:
pass

@abstractmethod
def put_programmatic_table_description(self, *, table_uri: str, description: ProgrammaticDescription) -> None:
pass

@abstractmethod
def add_read_count(self, *, table_uri: str, user_id: str, read_count: int) -> None:
pass
Loading

0 comments on commit c239a1f

Please sign in to comment.