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

Include Python accessible config descriptions #157

Open
3 tasks done
raphaelshirley opened this issue Jun 12, 2024 · 2 comments
Open
3 tasks done

Include Python accessible config descriptions #157

raphaelshirley opened this issue Jun 12, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@raphaelshirley
Copy link
Member

raphaelshirley commented Jun 12, 2024

Feature request
I would like to be able to see config definitions through Python. This might be achieved through a Python side set of definitions. This could also exist alongside config requirements that automatically check a config for consistency and that requirements are met.

In pseudo code:

Class lephareConfigParameter:
    def __init__(self,name=None,description=None,value=None,assertion=True):
        self.name=name
        self.definition=definition
        self.value=value
        self.assertion=assertion
    def check_value(self,config):
        assert assertion(config,self.value)

def check_err_scale(config,value):
    "Check errscale is the same length as other filter related parameters and that they exist"
    if "FILTER_LIST" not in config:
        print("FILTER_LIST is not present")
        return False    
    elif "FILTER_CALIB" not in config:
        print("FILTER_CALIB is not present")
        return False
    if  len(str(value).split(',')) != len(str(config["FILTER_LIST"]).split(','))
        print("FILTER_LIST and ERR_SCALE are different lengths")
        return False
    elif len(str(value).split(',')) != len(str(config["FILTER_CALIB"]).split(','))
        print("FILTER_CALIB and ERR_SCALE are different lengths")
        return False
    return True

allowed_config=dict(
    # All the allowed configs
    "ERR_SCALE": lephareConfigParameter(
        name="ERR_SCALE",
        description="The error scaling. Must be equal in length to FILTER_LIST and FILTER_CALIB",
        assertion=check_err_scale,
    )
         
]

required_config=[
    #configs that are required
    "ERR_SCALE",
]

def check_config(config):
    for c in config:
        assert c in allowed_config
        allowed_config[c].check_value()
    for c in required_config:
        assert c in config

Before submitting
Please check the following:

  • I have described the purpose of the suggested change, specifying what I need the enhancement to accomplish, i.e. what problem it solves.
  • I have included any relevant links, screenshots, environment information, and data relevant to implementing the requested feature, as well as pseudocode for how I want to access the new functionality.
  • If I have ideas for how the new feature could be implemented, I have provided explanations and/or pseudocode and/or task lists for the steps.
@raphaelshirley raphaelshirley added the enhancement New feature or request label Jun 12, 2024
@raphaelshirley raphaelshirley self-assigned this Jun 12, 2024
@raphaelshirley
Copy link
Member Author

@raphaelshirley
Copy link
Member Author

... which is based on CECI parameters:

https://github.com/LSSTDESC/ceci/blob/master/ceci/config.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant