FAIRChemistry/software-driven-rdm

add example done with the markup built models

Closed this issue · 3 comments

Would it be possible to build an example with the markdown built models. I tried to apply it and had a few struggles:

1. The test case was defined:

import sdRDM


from typing import Optional
from pydantic import PrivateAttr
from sdRDM.base.listplus import ListPlus
from pydantic import Field
from typing import Optional


class Enzyme(sdRDM.DataModel):

    """Do fugiat mollit sit duis deserunt dolor ex. Qu do occaeiscat dolor consectetur nostrud occaecat eu sint aute. Laboris commodo laborum proident id laboris cupidatat amet commodo tempor laborum sint occaecat mollit velit."""

    name: str = Field(
        ...,
        description="Name of the biocatalyst",
    )

    reaction: str = Field(
        ...,
        description="Reaction in which the biocatalyst is activ.",
    )


new = Enzyme(name="dadsad", reaction="fdsfdsfds")
print(new.json())

the response is:

C:\Users\SMalz\anaconda3\envs\strenda-biocatalyis\lib\site-packages\sdRDM\base\datamodel.py:77: UserWarning: No 'URL' and 'Commit' specified. This model might not be re-usable.
  warnings.warn(
{
  "name": "dadsad",
  "reaction": "fdsfdsfds"
}

2. Build model based on markdown

When a model is defined in markdown:

# Biocatalyst

Do fugiat mollit sit duis deserunt dolor ex. Quis do occaecat dolor consectetur nostrud occaecat eu sint aute. Laboris commodo laborum proident id laboris cupidatat amet commodo tempor laborum sint occaecat mollit velit. 

### BiocatalystBase

Do fugiat mollit sit duis deserunt dolor ex. Quis do occaecat dolor consectetur nostrud occaecat eu sint aute. Laboris commodo laborum proident id laboris cupidatat amet commodo tempor laborum sint occaecat mollit velit. 

- __name*__
  - Type: string
  - Description: Name of the biocatalyst
- __ecnumber__
  - Type: string
  - Description: Code used to determine the family of a protein.

The python specs are defined successful:

import sdRDM


from typing import Optional
from pydantic import PrivateAttr
from sdRDM.base.listplus import ListPlus
from pydantic import Field
from typing import Optional


class BiocatalystBase(sdRDM.DataModel):

    """Do fugiat mollit sit duis deserunt dolor ex. Quis do occaecat dolor consectetur nostrud occaecat eu sint aute. Laboris commodo laborum proident id laboris cupidatat amet commodo tempor laborum sint occaecat mollit velit."""

    name: str = Field(
        ...,
        description="Name of the biocatalyst",
    )

    ecnumber: Optional[str] = Field(
        description="Code used to determine the family of a protein.",
        default=None,
    )

    __repo__: Optional[str] = PrivateAttr(default="None")


new_enzyme = BiocatalystBase(name="enzyme", ecnumber="1232")

new_enzyme.json()

I get as response:

C:\Users\SMalz\anaconda3\envs\strenda-biocatalyis\lib\site-packages\sdRDM\base\datamodel.py:77: UserWarning: No 'URL' and 'Commit' specified. This model might not be re-usable.
  warnings.warn(
PS C:\Users\SMalz\Desktop\Repos\Strenda-biocatalysis> 

Thanks for the issue! This is not problematic, just a warning, that there is no commit or repo connected to the dataset. There is an action that I can send to you that will update the __repo__ and __commit__ such that whenever a dataset is created with the current version it can be re-parsed by fetching the state of the software following the commit.

You can find a template repo to use for your own purposes right here:

https://github.com/JR-1991/sdrdm-template

It includes the current GitHub Action workflow, but you need to specify LIB_NAME in the Action's secrets.

Thank's a lot, I tested this and opened another issue in JR-1991/sdrdm-template#2