Skip to content

Commit

Permalink
Fix typos and update environment variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
EvangMM committed Dec 12, 2023
1 parent 4ae173e commit 24db8f5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion core/digitalhub_core/client/objects/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_object(self, obj: dict, api: str) -> dict:
uuid = obj["id"]
self._db[dto].setdefault(name, {})
self._db[dto][name][uuid] = obj
self._db[dto][name]["latest"] = obj # For versioned objects set also latest version
self._db[dto][name]["latest"] = obj # For versioned objects set also latest version
return obj
except (KeyError, TypeError):
msg = self._format_msg(code)
Expand Down
4 changes: 2 additions & 2 deletions core/digitalhub_core/entities/runs/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from digitalhub_core.entities.dataitems.crud import get_dataitem_from_key
from digitalhub_core.runtimes.builder import build_runtime
from digitalhub_core.utils.api import api_base_create, api_base_read, api_base_update, api_ctx_read
from digitalhub_core.utils.commons import ARTF, DTIT, FUNC, LOGS, RUNS, TASK
from digitalhub_core.utils.commons import ARTF, DTIT, FUNC, RUNS, TASK
from digitalhub_core.utils.exceptions import EntityError
from digitalhub_core.utils.generic_utils import build_uuid, get_timestamp
from digitalhub_core.utils.io_utils import write_yaml
Expand Down Expand Up @@ -218,7 +218,7 @@ def logs(self) -> dict:
"""
if self._context().local:
return {}
api = api_base_read(LOGS, self.id)
api = api_base_read(RUNS, self.id) + f"/log"
return self._context().read_object(api)

def _set_status(self, status: dict) -> None:
Expand Down
16 changes: 8 additions & 8 deletions core/digitalhub_core/stores/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,23 @@ def get_env_store_config(scheme: str) -> StoreParameters:
name="s3",
type="s3",
config=S3StoreConfig(
endpoint_url=os.getenv("S3_ENDPOINT_URL"), # type: ignore
endpoint_url=os.getenv("DIGITALHUB_S3_ENDPOINT_URL"), # type: ignore
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), # type: ignore
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), # type: ignore
bucket_name=os.getenv("S3_BUCKET_NAME"), # type: ignore
bucket_name=os.getenv("DIGITALHUB_S3_BUCKET_NAME"), # type: ignore
),
)
if scheme == "sql":
return StoreParameters(
name="sql",
type="sql",
config=SQLStoreConfig(
host=os.getenv("POSTGRES_HOST"), # type: ignore
port=os.getenv("POSTGRES_PORT"), # type: ignore
user=os.getenv("POSTGRES_USER"), # type: ignore
password=os.getenv("POSTGRES_PASSWORD"), # type: ignore
database=os.getenv("POSTGRES_DATABASE"), # type: ignore
pg_schema=os.getenv("POSTGRES_SCHEMA"), # type: ignore
host=os.getenv("DIGITALHUB_POSTGRES_HOST"), # type: ignore
port=os.getenv("DIGITALHUB_POSTGRES_PORT"), # type: ignore
user=os.getenv("DIGITALHUB_POSTGRES_USER"), # type: ignore
password=os.getenv("DIGITALHUB_POSTGRES_PASSWORD"), # type: ignore
database=os.getenv("DIGITALHUB_POSTGRES_DATABASE"), # type: ignore
pg_schema=os.getenv("DIGITALHUB_POSTGRES_SCHEMA"), # type: ignore
),
)
if scheme == "remote":
Expand Down
12 changes: 6 additions & 6 deletions data/modules/dbt/digitalhub_core_dbt/runtime/dbt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
outputs:
dev:
type: postgres
host: {os.getenv("POSTGRES_HOST")}
user: {os.getenv("POSTGRES_USER")}
pass: {os.getenv("POSTGRES_PASSWORD")}
port: {os.getenv("POSTGRES_PORT")}
dbname: {os.getenv("POSTGRES_DATABASE")}
schema: {os.getenv("POSTGRES_SCHEMA", "public")}
host: {os.getenv("DIGITALHUB_POSTGRES_HOST")}
user: {os.getenv("DIGITALHUB_POSTGRES_USER")}
pass: {os.getenv("DIGITALHUB_POSTGRES_PASSWORD")}
port: {os.getenv("DIGITALHUB_POSTGRES_PORT")}
dbname: {os.getenv("DIGITALHUB_POSTGRES_DATABASE")}
schema: {os.getenv("DIGITALHUB_POSTGRES_SCHEMA", "public")}
target: dev
""".lstrip(
"\n"
Expand Down
20 changes: 14 additions & 6 deletions data/modules/dbt/digitalhub_core_dbt/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
from digitalhub_core.entities.dataitems.entity import Dataitem


HOST = os.getenv("DIGITALHUB_POSTGRES_HOST")
PORT = os.getenv("DIGITALHUB_POSTGRES_PORT")
USER = os.getenv("DIGITALHUB_POSTGRES_USER")
PASSWORD = os.getenv("DIGITALHUB_POSTGRES_PASSWORD")
DATABASE = os.getenv("DIGITALHUB_POSTGRES_DATABASE")
SCHEMA = os.getenv("DIGITALHUB_POSTGRES_SCHEMA", "public")


class RuntimeDBT(Runtime):
"""
Runtime DBT class.
Expand Down Expand Up @@ -223,7 +231,7 @@ def _materialize_dataitem(dataitem: Dataitem, name: str) -> str:
try:
table_name = f"{name}_v{dataitem.id}"
LOGGER.info(f"Materializing dataitem '{name}' as '{table_name}'.")
target_path = f"sql://{os.getenv('POSTGRES_DATABASE')}/{os.getenv('POSTGRES_SCHEMA')}/{table_name}"
target_path = f"sql://{DATABASE}/{SCHEMA}/{table_name}"
dataitem.write_df(target_path, if_exists="replace")
return table_name
except Exception:
Expand Down Expand Up @@ -449,11 +457,11 @@ def _get_connection() -> psycopg2.extensions.connection:
try:
LOGGER.info("Connecting to postgres.")
connection = psycopg2.connect(
host=os.getenv("POSTGRES_HOST"),
port=os.getenv("POSTGRES_PORT"),
database=os.getenv("POSTGRES_DATABASE"),
user=os.getenv("POSTGRES_USER"),
password=os.getenv("POSTGRES_PASSWORD"),
host=HOST,
port=PORT,
database=DATABASE,
user=USER,
password=PASSWORD,
)
connection.set_session(autocommit=True)
return connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
from nefertem.client.client import Client


####################
# Runtime
####################
BUCKET = os.getenv("DIGITALHUB_S3_BUCKET_NAME")


class RuntimeNefertem(Runtime):
Expand Down Expand Up @@ -460,7 +458,7 @@ def _create_artifact(name: str, project: str, run_id: str, src_path: str) -> Art
try:
# Get bucket name from env and filename from path
LOGGER.info(f"Creating artifact new artifact '{name}'.")
dst = f"s3://{os.getenv('S3_BUCKET_NAME')}/{project}/artifacts/ntruns/{run_id}/{Path(src_path).name}"
dst = f"s3://{BUCKET}/{project}/artifacts/ntruns/{run_id}/{Path(src_path).name}"
return new_artifact(project, name, "artifact", src_path=src_path, target_path=dst)
except Exception:
msg = f"Error creating artifact '{name}'."
Expand Down

0 comments on commit 24db8f5

Please sign in to comment.