Skip to content

Commit

Permalink
superficial fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bento007 committed Nov 16, 2022
1 parent 2001c87 commit 3a58992
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion server/common/config/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from flatten_dict import unflatten as _unflatten, flatten as _flatten

from server.common.errors import ConfigurationError
from server.common.config.config_model import Config
from server.common.config.config_model import AppConfigModel
from server.default_config import get_default_config


Expand Down
3 changes: 0 additions & 3 deletions server/common/config/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ def get_client_config(app_config: AppConfig, data_adaptor: Dataset, current_app)
"""
dataset_config = data_adaptor.app_config

# FIXME The current set of config is not consistently presented:
# we have camalCase, hyphen-text, and underscore_text

# make sure the configuration has been checked.
app_config.complete_config()

Expand Down
24 changes: 15 additions & 9 deletions server/common/config/config_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
"""
This module contains the configuration model used to validate the cellxgene configuration.
Note: `root_validator`s and class variables are executed in the order they are defined in the class definition.
"""

from __future__ import annotations

import os
import sys
import warnings
from enum import Enum
from typing import List, Optional, Union, Dict
from urllib.parse import quote_plus

Expand Down Expand Up @@ -67,8 +75,7 @@ def check_web_base_url(cls, values):
@validator("verbose")
def check_verbose(cls, value):
if not value:
pass
# sys.tracebacklimit = 0 # TODO undo
sys.tracebacklimit = 0
return value


Expand Down Expand Up @@ -111,6 +118,7 @@ def check_dataroot(cls, values):
base_urls = [d.base_url for d in values["dataroots"].values()]
if len(base_urls) > len(set(base_urls)):
raise ValueError("error in multi_dataset__dataroot: base_urls must be unique")
# TODO check that at least one dataroot is set. Then we can remove AppConfig.handle_data_source.
return values


Expand Down Expand Up @@ -150,7 +158,7 @@ class Server(BaseModel):
adaptor: Adaptor
limits: Limits

@root_validator(skip_on_failure=True) # TODO try skip_on_failure=True
@root_validator(skip_on_failure=True)
def check_data_locator(cls, values):
if values["data_locator"].s3_region_name is True:
path = values["multi_dataset"].dataroots or values["multi_dataset"].dataroot
Expand Down Expand Up @@ -181,13 +189,11 @@ def check_cxg_adaptor(cls, values):
return values


class ScriptsItem(BaseModel, extra=Extra.allow):
class ScriptsItem(BaseModel):
src: str

# class Config:
# extra = Extra.ignore
# integrity: Optional[str] = None
# crossorigin: Optional[str] = None
class Config:
extra = Extra.allow


class DatasetApp(BaseModel):
Expand Down Expand Up @@ -237,6 +243,6 @@ def check_x_approximate_distribution(cls, value):
return value


class Config(BaseModel):
class AppConfigModel(BaseModel):
server: Optional[Server]
default_dataset: Optional[DefaultDataset]
12 changes: 3 additions & 9 deletions server/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
web_base_url: null
multi_dataset:
# Dataroot must be set, then cellxgene may serve multiple datasets.
# dataroot may be a string, representing the path to a directory or S3 prefix. In this
# dataroot or dataroots must be set, then cellxgene may serve multiple datasets.
# dataroot must be a string, representing the path to a directory or S3 prefix. In this
# case the datasets in that location are accessed from <server>/d/<datasetname>.
# example:
# dataroot: /path/to/datasets/
# or
# dataroot: s3://bucket/prefix/
#
# As an alternative, dataroot can be a dictionary, where a dataset key is associated with a base_url
# dataroots can be a dictionary, where a dataset key is associated with a base_url
# and a dataroot.
# example:
# dataroots:
Expand Down Expand Up @@ -105,12 +105,6 @@
count: 15
X_approximate_distribution: normal # currently fixed config
# You can retrieve configuration parameters from this config file, the environment,
# the AWS secrets manager, or from the "cellxgene launch" command line arguments.
# They are applied in that order, meaning that if a parameter is defined in more
# than one location, the last one applied takes effect.
"""


Expand Down

0 comments on commit 3a58992

Please sign in to comment.