smart-data-models / data-models

Data Models in common use based on real world use-cases. These definitions underpin a digital market of interoperable and replicable smart solutions.
https://smartdatamodels.org/
114 stars 56 forks source link

Feat/cli 22w39 initial prototype #39

Closed auphofBSF closed 2 years ago

auphofBSF commented 2 years ago

Change Proposal - (WIP for review/suggestions/discussion)

Whilst I am integrating aspects of the SmartDataModels into some of our applications, I see there being great benefit to enhancing the work in various scripts particularly pysmartdatamodels . This PR is there for discussion and suggestions. Possibly the pysmartdatamodels should be its own repo within Smart-data-models rather than a folder within this repo data-models

Demonstration of functionality can be found in https://colab.research.google.com/drive/1D8jZ6-sOGCksAtJ6NUHv9yk6ONvjKJBc?usp=sharing

1) move setup.py towards compatibility with current package managers, fix issues and moves towards PEP621 covering PEP517 and PEP518, tested against pip 21.x and poetry 1.2.1 2) introduce a CLI that essential automatically exports functions that were available in an easy to use CLI pysmartdatamodel_cli --help 3) setup a pytest framework

✅installing this with poetry using poetry add ...... works now as expected , including in --editable mode ✅installing this with pip install .......

breaking changes

the pysmartdatamodels.py is turned into a module with all the functions copied across into pysmartdatamodels/commands.py. Only minor alterations are the relocation of the official_list_data_models.json into a folder pysmartdatamodel/model-assets/ and the change of https://github.com/smart-data-models/data-models/blob/cb958f2a1a81256f4b400163fd5427688289b479/pysmartdatamodels/pysmartdatamodels.py#L326 validate_data_model_schema(schemaUrl) to validate_data_model_schema(schema_url) for some reason the CLI auto generator does not want to recognize schemaUrl

wistefan commented 2 years ago

Hi, thanks for the contribution. The changes look go to me. I agree, moving the pysmartdatamodels into its own repo would make sense. The lifecycle management should be easier and more clear. @albertoabellagarcia what do you think about that?