Skip to content

Commit

Permalink
feat(connector): add functionality that lists supported websites
Browse files Browse the repository at this point in the history
  • Loading branch information
nzrymiak committed Feb 6, 2021
1 parent 57effc9 commit 88187e1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dataprep/connector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

from .connector import Connector
from .generator import ConfigGenerator, ConfigGeneratorUI
from .info import info
from .info import info, websites

__all__ = [
"Connector",
"ConfigGenerator",
"ConfigGeneratorUI",
"connect",
"info",
"websites",
]


Expand Down
35 changes: 34 additions & 1 deletion dataprep/connector/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from typing import Any, Dict, List

import pandas as pd
from IPython.display import display

from ..utils import get_styled_schema
from ..utils import get_styled_schema, is_notebook
from .implicit_database import ImplicitDatabase
from .info_ui import info_ui
from .schema import ConfigDef
Expand Down Expand Up @@ -111,3 +112,35 @@ def get_schema(schema: Dict[str, Any]) -> pd.DataFrame:
new_schema_dict["data_type"].append(schema[k].type)

return pd.DataFrame.from_dict(new_schema_dict)


def websites() -> None:
"""Displays names of websites supported by data connector."""
websites = {
"business": ["yelp"],
"finance": ["finnhub"],
"geocoding": ["mapquest"],
"lifestyle": ["spoonacular"],
"music": ["musixmatch", "spotify"],
"news": ["guardian", "times"],
"science": ["dblp"],
"shopping": ["etsy"],
"social": ["twitch", "twitter"],
"video": ["youtube"],
"weather": ["openweathermap"],
}

supported_websites = pd.DataFrame.from_dict(websites, orient="index")
supported_websites = supported_websites.transpose()
supported_websites.columns = supported_websites.columns.str.upper()

# replace "None" values with empty string
mask = supported_websites.applymap(lambda x: x is None)
cols = supported_websites.columns[(mask).any()]
for col in supported_websites[cols]:
supported_websites.loc[mask[col], col] = ""

if is_notebook():
display(supported_websites)
else:
print(supported_websites.to_string(index=False))
4 changes: 3 additions & 1 deletion dataprep/tests/connector/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
import pytest

from ...connector import Connector
from ...connector import Connector, websites
from ...utils import display_dataframe
from ...connector.utils import Request

Expand All @@ -19,6 +19,8 @@ def test_connector() -> None:

assert len(df) > 0

websites()

dc.info()

display_dataframe(df)
Expand Down

0 comments on commit 88187e1

Please sign in to comment.