Skip to content

Commit

Permalink
Reworked the project structure and fixed import cycling issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Suchismit4 committed Jan 14, 2025
1 parent 257714c commit c6a5dbd
Show file tree
Hide file tree
Showing 47 changed files with 52 additions and 1,232 deletions.
Binary file modified src/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions src/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from pathlib import Path
from typing import Optional

from .provider import _PROVIDER_REGISTRY
from src.data.core import *
from src.data.core.provider import _PROVIDER_REGISTRY

def get_default_cache_root() -> str:
"""Returns the default cache root directory."""
Expand Down Expand Up @@ -36,4 +37,4 @@ def initialize_cache_directories(cache_root: Optional[str] = None):
# Run the initialization function when the module is imported
initialize_cache_directories()

from .manager import DataManager
from .managers.data_manager import DataManager
Binary file modified src/data/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified src/data/core/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
3 changes: 0 additions & 3 deletions src/data/core/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import math
import numpy as np
import pandas as pd
import xarray as xr
import jax
import xarray_jax as xj
import jax.numpy as jnp
import equinox as eqx
from typing import Union, Dict, List, Optional, Tuple, Any, Callable
Expand Down
Binary file modified src/data/core/operations/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
5 changes: 2 additions & 3 deletions src/data/provider.py → src/data/core/provider.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# src/data/provider.py

from typing import Dict, Type
from .abstracts.base import BaseDataSource
from typing import Dict, Any

class Provider:
def __init__(
self,
name: str,
website: str,
description: str,
fetcher_dict: Dict[str, Type[BaseDataSource]],
fetcher_dict: Dict[str, Any],
repr_name: str = None,
):
self.name = name
Expand Down
5 changes: 5 additions & 0 deletions src/data/loaders/abstracts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Abstract base classes for data loaders.
"""

from .base import BaseDataSource
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# src/data/loaders/base.py
# src/data/loaders/abstracts/base.py

import os
import pandas as pd
Expand All @@ -9,11 +9,9 @@
import hashlib
from abc import ABC, abstractmethod

from ..core.struct import DatasetDateTimeAccessor
from ..core.util import FrequencyType
from ..core.util import Loader as load

from ..processors_registry import post_processor
from src.data.core.util import FrequencyType
from src.data.core.util import Loader as load
from src.data.processors.registry import post_processor

class BaseDataSource(ABC):
"""
Expand Down Expand Up @@ -192,7 +190,7 @@ def load_from_cache(
try:
ds = xr.load_dataset(netcdf_path) # or xr.open_dataset, either is OK

from ..core.util import TimeSeriesIndex
from src.data.core import TimeSeriesIndex

time_coord = ds.coords['time']
ts_index = TimeSeriesIndex(time_coord)
Expand Down
6 changes: 5 additions & 1 deletion src/data/loaders/open_bb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# data/loaders/openbb/__init__.py

from ...provider import Provider, register_provider
"""
OpenBB data loaders and provider registration.
"""

from src.data.core.provider import Provider, register_provider
from .generic import GenericOpenBBDataFetcher
from openbb import obb

Expand Down
Binary file modified src/data/loaders/open_bb/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified src/data/loaders/open_bb/__pycache__/generic.cpython-312.pyc
Binary file not shown.
6 changes: 5 additions & 1 deletion src/data/loaders/open_bb/generic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# data/loaders/openbb/generic.py

from src.data.abstracts.base import BaseDataSource
"""
Generic OpenBB data fetcher implementation.
"""

from src.data.loaders.abstracts.base import BaseDataSource
from typing import Dict, Any, List
import xarray as xr
import pandas as pd
Expand Down
6 changes: 5 additions & 1 deletion src/data/loaders/wrds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# data/loaders/wrds/__init__.py

from ...provider import Provider, register_provider
"""
WRDS data loaders and provider registration.
"""

from src.data.core.provider import Provider, register_provider

# Fetchers
from .compustat import CompustatDataFetcher
Expand Down
Binary file modified src/data/loaders/wrds/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified src/data/loaders/wrds/__pycache__/compustat.cpython-312.pyc
Binary file not shown.
Binary file modified src/data/loaders/wrds/__pycache__/crsp.cpython-312.pyc
Binary file not shown.
Binary file modified src/data/loaders/wrds/__pycache__/generic.cpython-312.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion src/data/loaders/wrds/crsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@ def _preprocess_df(self, df: pd.DataFrame, **config) -> pd.DataFrame:
)
except Exception as e:
print(f"Warning: Could not merge msedelist data due to error: {e}")



return df
8 changes: 6 additions & 2 deletions src/data/loaders/wrds/generic.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# data/loaders/wrds/generic.py

"""
Generic WRDS data loader implementation.
"""

import os
from typing import Any, Dict, List, Optional, Union
import pandas as pd
import xarray as xr
import pyreadstat

from src.data.abstracts.base import BaseDataSource
from src.data.core import FrequencyType
from src.data.loaders.abstracts.base import BaseDataSource
from src.data.core.util import FrequencyType

class GenericWRDSDataLoader(BaseDataSource):
"""
Expand Down
5 changes: 5 additions & 0 deletions src/data/managers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Managers for centralized control over data operations.
"""

from .data_manager import DataManager
Binary file not shown.
Binary file not shown.
3 changes: 1 addition & 2 deletions src/data/manager.py → src/data/managers/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import xarray as xr
import xarray_jax
from xarray import DataTree

from typing import Union, List, Dict, Any
import os
import yaml

from .provider import _PROVIDER_REGISTRY
from src.data.core.provider import _PROVIDER_REGISTRY
from src.data.loaders import *

class DataManager:
Expand Down
6 changes: 6 additions & 0 deletions src/data/processors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Data processing utilities and registries.
"""

from .registry import post_processor
from .processors import *
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion src/data/processors.py → src/data/processors/processors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# src/data/processors.py

from processors_registry import post_processor
from src.data.processors.registry import post_processor
import xarray
from typing import *

@post_processor
def processor_test(funcs: Dict[str, Any], ds: xarray.Dataset) -> xarray.Dataset:
Expand Down
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
142 changes: 0 additions & 142 deletions src/deperecated/data_layer/coords.py

This file was deleted.

Loading

0 comments on commit c6a5dbd

Please sign in to comment.