-
Notifications
You must be signed in to change notification settings - Fork 120
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
14 changed files
with
1,272 additions
and
584 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
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,57 @@ | ||
from typing import Any, Dict, List, Optional | ||
import uuid | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
DEFAULT_TIMEOUT = 60 * 60 * 24 | ||
|
||
|
||
class PythonJobConfig(BaseModel): | ||
"""Pydantic model for config found in python_job_config.""" | ||
|
||
name: Optional[str] = None | ||
grants: Dict[str, List[Dict[str, str]]] = Field(exclude=True, default_factory=dict) | ||
existing_job_id: str = Field("", exclude=True) | ||
post_hook_tasks: List[Dict[str, Any]] = Field(exclude=True, default_factory=list) | ||
additional_task_settings: Dict[str, Any] = Field(exclude=True, default_factory=dict) | ||
|
||
class Config: | ||
extra = "allow" | ||
|
||
|
||
class PythonModelConfig(BaseModel): | ||
""" | ||
Pydantic model for a Python model configuration. | ||
Includes some job-specific settings that are not yet part of PythonJobConfig. | ||
""" | ||
|
||
user_folder_for_python: bool = False | ||
timeout: int = Field(DEFAULT_TIMEOUT, gt=0) | ||
job_cluster_config: Dict[str, Any] = Field(default_factory=dict) | ||
access_control_list: List[Dict[str, str]] = Field(default_factory=list) | ||
packages: List[str] = Field(default_factory=list) | ||
index_url: Optional[str] = None | ||
additional_libs: List[Dict[str, Any]] = Field(default_factory=list) | ||
python_job_config: PythonJobConfig = Field(default_factory=lambda: PythonJobConfig(**{})) | ||
cluster_id: Optional[str] = None | ||
http_path: Optional[str] = None | ||
create_notebook: bool = False | ||
|
||
|
||
class ParsedPythonModel(BaseModel): | ||
"""Pydantic model for a Python model parsed from a dbt manifest""" | ||
|
||
catalog: str = Field("hive_metastore", alias="database") | ||
|
||
# Schema is a reserved name in Pydantic | ||
schema_: str = Field("default", alias="schema") | ||
|
||
identifier: str = Field(alias="alias") | ||
config: PythonModelConfig | ||
|
||
@property | ||
def run_name(self) -> str: | ||
return f"{self.catalog}-{self.schema_}-{self.identifier}-{uuid.uuid4()}" | ||
|
||
class Config: | ||
allow_population_by_field_name = True |
Oops, something went wrong.