-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
65 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from odd_dbt.logger import logger | ||
|
||
|
||
def get_version() -> str: | ||
try: | ||
from odd_cli.__version__ import VERSION | ||
return VERSION | ||
except ImportError: | ||
logger.warning("Can't get version from odd_dbt.__version__") | ||
return "0.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VERSION = "0.0.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
import typer | ||
from oddrn_generator import FilesystemGenerator | ||
|
||
from odd_cli.client import Client | ||
from odd_cli.logger import logger | ||
from odd_cli.reader.reader import read | ||
|
||
app = typer.Typer( | ||
short_help="Collect and ingest metadata for local files from folder", | ||
pretty_exceptions_show_locals=False, | ||
) | ||
|
||
@app.callback() | ||
def collect( | ||
folder: Path = typer.Argument(..., exists=True, resolve_path=True), | ||
platform_host: str = typer.Option(..., "--host", "-h", envvar="ODD_PLATFORM_HOST"), | ||
platform_token: str = typer.Option( | ||
..., "--token", "-t", envvar="ODD_PLATFORM_TOKEN" | ||
), | ||
): | ||
"Collect and ingest metadata for local files from folder" | ||
client = Client(host=platform_host, token=platform_token) | ||
|
||
generator = FilesystemGenerator(host_settings="local") | ||
|
||
client.create_data_source( | ||
data_source_oddrn=generator.get_data_source_oddrn(), | ||
data_source_name="local_files", | ||
) | ||
|
||
data_entities = read(path=folder, generator=generator) | ||
|
||
client.ingest_data_entity_list(data_entities=data_entities) | ||
|
||
logger.success(f"Ingested {len(data_entities.items)} datasets") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,3 @@ def create( | |
|
||
print(token) | ||
return token | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,28 @@ | ||
from pathlib import Path | ||
|
||
import typer | ||
from odd_dbt.app import app as dbt_test_app | ||
from oddrn_generator.generators import FilesystemGenerator | ||
|
||
from odd_cli.client import Client | ||
from odd_cli.logger import logger | ||
from odd_cli.reader.reader import read | ||
from odd_cli.tokens import app as tokens_app | ||
from odd_cli.__version__ import VERSION | ||
from odd_cli.apps.metadata import app as collect_app | ||
from odd_cli.apps.tokens import app as tokens_app | ||
|
||
app = typer.Typer(pretty_exceptions_show_locals=False) | ||
|
||
app.add_typer( | ||
collect_app, | ||
) | ||
app.add_typer( | ||
tokens_app, | ||
name="tokens", | ||
) | ||
app.add_typer(dbt_test_app, name="dbt") | ||
|
||
|
||
@app.command() | ||
def collect( | ||
folder: Path = typer.Argument(..., exists=True, resolve_path=True), | ||
platform_host: str = typer.Option(..., "--host", "-h", envvar="ODD_PLATFORM_HOST"), | ||
platform_token: str = typer.Option( | ||
..., "--token", "-t", envvar="ODD_PLATFORM_TOKEN" | ||
), | ||
def version( | ||
short: bool = typer.Option(False, "--short", "-s", help="Print only version number") | ||
): | ||
"Collect and ingest metadata for local files from folder" | ||
client = Client(host=platform_host, token=platform_token) | ||
|
||
generator = FilesystemGenerator(host_settings="local") | ||
|
||
client.create_data_source( | ||
data_source_oddrn=generator.get_data_source_oddrn(), | ||
data_source_name="local_files", | ||
) | ||
|
||
data_entities = read(path=folder, generator=generator) | ||
|
||
client.ingest_data_entity_list(data_entities=data_entities) | ||
|
||
logger.success(f"Ingested {len(data_entities.items)} datasets") | ||
|
||
|
||
@app.callback() | ||
def callback(): | ||
... | ||
"Print version" | ||
if short: | ||
print(VERSION) | ||
else: | ||
print(f"odd-cli version: {VERSION}") |