Skip to content

Commit

Permalink
Handle crawler timeout gracefully (#980)
Browse files Browse the repository at this point in the history
* move parse arg to metaphor.cli

* Bump version

* Bump version
  • Loading branch information
elic-eon authored Sep 6, 2024
1 parent c770e37 commit fddb6a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 5 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__pycache__/
*.py[cod]
*$py.class
*
!metaphor
!README.md
!pyproject.toml
!poetry.lock
12 changes: 3 additions & 9 deletions metaphor/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import subprocess
from importlib import import_module

from metaphor.common.cli import parse_args
from metaphor.common.logger import get_logger

logger = get_logger()
Expand All @@ -19,19 +19,13 @@ def print_packages():
def main():
print_packages()

parser = argparse.ArgumentParser(description="Metaphor Connectors")

parser.add_argument(
"name", help="Name of the connector, e.g. snowflake or bigquery"
)
parser.add_argument("config", help="Path to the config file")
args = parser.parse_args()
args = parse_args()

package_main = getattr(import_module(f"metaphor.{args.name}"), "main", None)
if package_main is None:
raise ValueError(f"Unable to load {args.package}:main")

logger.info(f"Executing {args.name} connector with config file {args.config}")

package_main(args.config)


Expand Down
12 changes: 12 additions & 0 deletions metaphor/common/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
from typing import Type

from metaphor.common.base_config import BaseConfig
Expand All @@ -6,6 +7,17 @@
from metaphor.common.runner import run_connector


def parse_args():
parser = argparse.ArgumentParser(description="Metaphor Connectors")

parser.add_argument(
"name", help="Name of the connector, e.g. snowflake or bigquery"
)
parser.add_argument("config", help="Path to the config file")
args = parser.parse_args()
return args


def cli_main(extractor_cls: Type[BaseExtractor], config_file: str):
base_config = BaseConfig.from_yaml_file(config_file)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.14.101"
version = "0.14.102"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down

0 comments on commit fddb6a9

Please sign in to comment.