Skip to content

Commit

Permalink
remove the error message (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
SerRichard authored May 30, 2024
1 parent b334c77 commit eb36cbc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
40 changes: 18 additions & 22 deletions openeo_fastapi/cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""CLI to support quick initialisation of the project source directory."""
from pathlib import Path

import click
import fsspec

from alembic import command
from alembic.config import Config
from pathlib import Path

from openeo_fastapi.templates import (
get_app_template,
get_models_template,
get_revision_template
get_revision_template,
)


Expand All @@ -18,61 +18,57 @@ def cli():
"""Defining group for executor CLI."""
pass


@click.command()
@click.option('--path', default=None, type=str)
@click.option("--path", default=None, type=str)
def new(path):
"""Initialize a source directory for an openeo_fastapi api project at the specified location."""
fs = fsspec.filesystem(protocol="file")

if path:
path = Path(path)
if not path.exists():
raise ValueError("Provided path does not exist.")
else:
path = Path(fs.get_mapper("").root)

openeo_dir = path
db_dir = openeo_dir / "psql"
init_file = openeo_dir / "__init__.py"
app_file = openeo_dir / "app.py"
revise_file = openeo_dir / "revise.py"


alembic_dir = db_dir / "alembic"
alembic_models = db_dir / "models.py"
alembic_ini = db_dir / "alembic.ini"

fs.mkdir(openeo_dir)

fs.mkdir(db_dir)

fs.mkdir(alembic_dir)

fs.touch(alembic_models)
with fs.open(alembic_models, 'w') as f:
with fs.open(alembic_models, "w") as f:
f.write(get_models_template())

alembic_cfg = Config(alembic_ini)

command.init(
alembic_cfg,
directory=alembic_dir
)


command.init(alembic_cfg, directory=alembic_dir)

fs.touch(init_file)

fs.touch(app_file)
with fs.open(app_file, 'w') as f:
with fs.open(app_file, "w") as f:
f.write(get_app_template())

revise_file = openeo_dir / "revise.py"
fs.touch(revise_file)
with fs.open(revise_file, 'w') as f:
with fs.open(revise_file, "w") as f:
f.write(get_revision_template())

pass


cli.add_command(new)

if __name__ == '__main__':
if __name__ == "__main__":
cli()
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 = "openeo-fastapi"
version = "2024.5.1"
version = "2024.5.2"
description = "FastApi implementation conforming to the OpenEO Api specification."
authors = ["Sean Hoyal <sean.hoyal@external.eodc.eu>"]
readme = "README.md"
Expand Down

0 comments on commit eb36cbc

Please sign in to comment.