# AUTOGENERATED! DO NOT EDIT! File to edit: 00_jobs.ipynb (unless otherwise specified).

__all__ = ['get_client_async', 'get_client', 'MakeSampleDataJob', 'PreprocessingJob', 'FeatureCalcJob',
           'TrainingDataJob', 'TrainModelJob', 'PrepareDbJob']

# Cell
from typing import Dict, Optional, Any

from hopeit.app.context import EventContext
from dataclasses import dataclass, field
from hopeit.dataobjects import dataobject

# Cell
async def get_client_async(context: Optional[EventContext] = None):
    from dask.distributed import Client
    url = "local" if context is None else context.env['dask']['url']
    if url == "local":
        client = await Client(asynchronous=True)
    else:
        client = await Client(url, asynchronous=True)
    return client

def get_client(context: Optional[EventContext] = None):
    from dask.distributed import Client
    url = "local" if context is None else context.env['dask']['url']
    if url == "local":
        client = Client()
    else:
        client = Client(url)
    return client



# Cell
@dataobject
@dataclass
class MakeSampleDataJob:
    path: str
    num_batches: int = 0
    batch_size: int = 0
    batch_span_days: int = 0
    num_customers: int = 0
    num_emails: int = 0
    num_ips: int = 0

# Cell
@dataobject
@dataclass
class PreprocessingJob:
    source: str
    partitioned: Dict[str, str] = field(default_factory=dict)

# Cell
@dataobject
@dataclass
class FeatureCalcJob:
    sources: Dict[str, str] = field(default_factory=dict)
    features: Dict[str, str] = field(default_factory=dict)

# Cell
@dataobject
@dataclass
class TrainingDataJob:
    sources: Dict[str, str]
    sampled: str
    validation: str

# Cell
@dataobject
@dataclass
class TrainModelJob:
    train_data: str
    validation_data: str
    model_path: str
    evals: Dict[str, Any] = field(default_factory=dict)
    test_roc_curve: Dict[float, float] = field(default_factory=dict)
    validation_score: Dict[str, float] = field(default_factory=dict)

# Cell
@dataobject
@dataclass
class PrepareDbJob:
    features: Dict[str, str]
    db: str
    saved: Dict[str, Any]
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_jobs.ipynb (unless otherwise specified).

__all__ = ['get_client_async', 'get_client', 'MakeSampleDataJob', 'PreprocessingJob', 'FeatureCalcJob',
           'TrainingDataJob', 'TrainModelJob', 'PrepareDbJob']

# Cell
from typing import Dict, Optional, Any

from hopeit.app.context import EventContext
from dataclasses import dataclass, field
from hopeit.dataobjects import dataobject

# Cell
async def get_client_async(context: Optional[EventContext] = None):
    from dask.distributed import Client
    url = "local" if context is None else context.env['dask']['url']
    if url == "local":
        client = await Client(asynchronous=True)
    else:
        client = await Client(url, asynchronous=True)
    return client

def get_client(context: Optional[EventContext] = None):
    from dask.distributed import Client
    url = "local" if context is None else context.env['dask']['url']
    if url == "local":
        client = Client()
    else:
        client = Client(url)
    return client



# Cell
@dataobject
@dataclass
class MakeSampleDataJob:
    path: str
    num_batches: int = 0
    batch_size: int = 0
    batch_span_days: int = 0
    num_customers: int = 0
    num_emails: int = 0
    num_ips: int = 0

# Cell
@dataobject
@dataclass
class PreprocessingJob:
    source: str
    partitioned: Dict[str, str] = field(default_factory=dict)

# Cell
@dataobject
@dataclass
class FeatureCalcJob:
    sources: Dict[str, str] = field(default_factory=dict)
    features: Dict[str, str] = field(default_factory=dict)

# Cell
@dataobject
@dataclass
class TrainingDataJob:
    sources: Dict[str, str]
    sampled: str
    validation: str

# Cell
@dataobject
@dataclass
class TrainModelJob:
    train_data: str
    validation_data: str
    model_path: str
    evals: Dict[str, Any] = field(default_factory=dict)
    test_roc_curve: Dict[float, float] = field(default_factory=dict)
    validation_score: Dict[str, float] = field(default_factory=dict)

# Cell
@dataobject
@dataclass
class PrepareDbJob:
    features: Dict[str, str]
    db: str
    saved: Dict[str, Any]
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_jobs.ipynb (unless otherwise specified). # Cell # Cell # Cell # Cell # Cell # Cell # Cell # Cell