Skip to content

Commit

Permalink
remove unused code and update requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Nov 7, 2023
1 parent 4d09fa6 commit 88283c0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 52 deletions.
17 changes: 0 additions & 17 deletions offsets_db_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@ def check_get_url(cls, v, values):
return v


class ConfigItem(pydantic.BaseModel):
"""Configuration item"""

name: typing.Literal['projects', 'issuances', 'retirements', 'cancellations', 'transactions']
urls: Urls
data: dict | str | None
headers: dict | None


class Configuration(pydantic.BaseModel):
projects: ConfigItem | None
issuances: ConfigItem | None
retirements: ConfigItem | None
cancellations: ConfigItem | None
transactions: ConfigItem | None


project_schema = pa.DataFrameSchema(
{
'protocol': pa.Column(pa.Object, nullable=True), # Array of strings
Expand Down
29 changes: 1 addition & 28 deletions offsets_db_data/registry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import typing

import upath

from offsets_db_data.models import Configuration, RegistryType

REGISTRY_ABBR_MAP = {
'vcs': 'verra',
'car': 'climate-action-reserve',
Expand All @@ -22,25 +16,4 @@ def get_registry_from_project_id(project_id: str) -> str:
# somdeday should probably go in a `project` class
return 'gold-standard'
else:
return REGISTRY_ABBR_MAP.get(lowered_id[:3])


def get_registry_configs(*, config_dir: upath.UPath | None = None) -> dict[str, upath.UPath]:
"""Get registry configuration files"""
if config_dir is None:
# load from default location packaged with the library
config_dir = upath.UPath(__file__).parent / 'configs'
config_dir = upath.UPath(config_dir)
if not (files := sorted(config_dir.glob('*.json'))):
raise ValueError(f'No JSON files found in {config_dir}')

return {
file.stem: file for file in files if file.stem in typing.get_args(RegistryType)
} # retrieve the argumens with which the Literal was initialized


def load_registry_config(registry_name: str):
configs = get_registry_configs()
if registry_name not in configs:
raise ValueError(f'No configuration file found for {registry_name}')
return Configuration.parse_file(configs[registry_name])
return REGISTRY_ABBR_MAP[lowered_id[:3]]
7 changes: 0 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
beautifulsoup4==4.12.2
boto3==1.28.*
brotli==1.1.0
chardet==5.2.0
country_converter==1.0.0
fastparquet==2023.7.*
fsspec==2023.9.*
html5lib==1.1.*
lxml==4.9.*
openpyxl==3.1.*
pandas==2.1.1
pandera==0.17
pydantic==1.10.*
Expand Down

0 comments on commit 88283c0

Please sign in to comment.