Skip to content

Commit

Permalink
chore: add version printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Vixtir committed Jul 14, 2023
1 parent a2b9fe8 commit 37f3efb
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 38 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/create_pypi_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
virtualenvs-create: false

- name: Patch package version
run: poetry version ${{ inputs.bump_rule }}
run: |
poetry version ${{ inputs.bump_rule }}
echo "VERSION = '$(poetry version -s)'" > odd_cli/__version__.py
- name: Run Dockerfile to build and publish package into PyPI
run: |
Expand Down
10 changes: 10 additions & 0 deletions odd_cli/__init__.py
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"
1 change: 1 addition & 0 deletions odd_cli/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "0.0.0"
Empty file added odd_cli/apps/__init__.py
Empty file.
37 changes: 37 additions & 0 deletions odd_cli/apps/metadata.py
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")
4 changes: 0 additions & 4 deletions odd_cli/tokens.py → odd_cli/apps/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ def create(

print(token)
return token


if __name__ == "__main__":
app()
47 changes: 14 additions & 33 deletions odd_cli/main.py
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}")

0 comments on commit 37f3efb

Please sign in to comment.