Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dataset_index client #21

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
13 changes: 13 additions & 0 deletions cmsdials/clients/dataset_index/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from ...utils.api_client import BaseAuthorizedAPIClient
from .models import DatasetIndex, DatasetIndexFilters, PaginatedDatasetIndexList


class DatasetIndexClient(BaseAuthorizedAPIClient):
data_model = DatasetIndex
pagination_model = PaginatedDatasetIndexList
filter_class = DatasetIndexFilters
lookup_url = "dataset-index/"

def get(self, dataset_id: int, file_id: int, **kwargs):
edp = f"{dataset_id}/{file_id}/"
return super().get(edp, **kwargs)
30 changes: 30 additions & 0 deletions cmsdials/clients/dataset_index/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from datetime import datetime
from typing import Optional

from pydantic import AnyUrl, BaseModel, Field

from ...utils.base_model import OBaseModel, PaginatedBaseModel


class DatasetIndex(BaseModel):
dataset_id: int
dataset: str = Field(..., max_length=255)
era: str = Field(..., max_length=255)
data_tier: str = Field(..., max_length=255)
primary_ds_name: str = Field(..., max_length=255)
processed_ds_name: str = Field(..., max_length=255)
processing_version: int
last_modification_date: datetime


class PaginatedDatasetIndexList(PaginatedBaseModel):
next: Optional[AnyUrl]
previous: Optional[AnyUrl]
results: list[DatasetIndex]


class DatasetIndexFilters(OBaseModel):
next_token: Optional[str] = None
page_size: Optional[int] = None
dataset: Optional[str] = None
dataset__regex: Optional[str] = None
2 changes: 2 additions & 0 deletions cmsdials/cmsdials.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional

from .auth._base import BaseCredentials
from .clients.dataset_index.client import DatasetIndexClient
from .clients.file_index.client import FileIndexClient
from .clients.h1d.client import LumisectionHistogram1DClient
from .clients.h2d.client import LumisectionHistogram2DClient
Expand All @@ -14,6 +15,7 @@

class Dials:
def __init__(self, creds: BaseCredentials, workspace: Optional[str] = None, *args, **kwargs) -> None:
self.dataset_index = DatasetIndexClient(creds, workspace, *args, **kwargs)
self.file_index = FileIndexClient(creds, workspace, *args, **kwargs)
self.h1d = LumisectionHistogram1DClient(creds, workspace, *args, **kwargs)
self.h2d = LumisectionHistogram2DClient(creds, workspace, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions cmsdials/filters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .clients.dataset_index.models import DatasetIndexFilters
from .clients.file_index.models import FileIndexFilters
from .clients.h1d.models import LumisectionHistogram1DFilters
from .clients.h2d.models import LumisectionHistogram2DFilters
Expand All @@ -10,6 +11,7 @@


__all__ = [
"DatasetIndexFilters",
"FileIndexFilters",
"LumisectionHistogram1DFilters",
"LumisectionHistogram2DFilters",
Expand Down