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

ApiDoc Automation script created & mock portfolio data generator refectored. #17

Merged
merged 4 commits into from
Jul 1, 2021

Conversation

Purvanshsingh
Copy link
Member

@Purvanshsingh Purvanshsingh commented Jun 29, 2021

Fixes #15

As of now, we create all the classes and properties in ApiDoc using docwriter.py manually.
I have created the script which will parse the NonPerformingLoan.jsonld and can create hydra classes & properties for ApiDoc.

NonPerformingLoan.jsonld --> ApiDoc

Methods used to parse the jsonld-ld are defined in NPLVocab_parser.py
It can be used as:

import NPLVocab_parse as parser

npl_vocab = parser.get_npl_vocab()
classes = parser.get_all_classes(npl_vocab)
hydra_classes = parser.create_hydra_classes(classes)

The ApiDoc generated by the new script is tested with the postman. and all the tests are passing as well.

We just need to run docwriter.py to create new ApiDoc everytime it will generate classes & properties from JSON-LD.

Screenshot from 2021-06-29 18-44-45

mock_porfolio_generator.py is also refactored.
creating objects in sequence.

CounterParty --> Loan --> Collateral

Copy link
Member

@farazkhanfk7 farazkhanfk7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great. Also tested NPLVocab_parser.
Suggestion : get_npl_vocab function will give FileNotFoundError for NonPerformingLoan.jsonld. It only works when api_docwriter.py is ran from terminal ( cd : exact file path).
To solve file path issue you can use something like :

from pathlib import Path
from os.path import abspath, dirname

cwd_path = Path(dirname(dirname(abspath(__file__))))
vocab_file_path = cwd_path / "npl_vocab" / "NonPerformingLoan.jsonld"

@open-risk
Copy link
Contributor

I would put the portfolio generator script in a separate directory. In principle this is not a test but a mock client.

@open-risk
Copy link
Contributor

on the vocabulary parser, should there be different treatment of data properties versus object properties? actually not sure what the later (object properties) are mapped into. in any case data properties are the immediate focus

@Purvanshsingh
Copy link
Member Author

@open-risk probably after merging this PR you can remove and put it in a separate directory.
As this commits consists some changes to portfolio generator as well.

@Purvanshsingh
Copy link
Member Author

Purvanshsingh commented Jul 1, 2021

Object property in our JSON-LD is acting as FOREIGN KEY.
which is handled here :

https://github.com/Purvanshsingh/creditrisk-poc/blob/cebf08b38301f449566fda25f937b40ce8c65f8b/creditrisk_poc/api_doc/NPLVocab_parser.py#L52-L55

For object property the property_uri is the id of the linking class.

@Purvanshsingh
Copy link
Member Author

@open-risk please do approve these changes so that we can merge this PR.

@open-risk
Copy link
Contributor

Object property in our JSON-LD is acting as FOREIGN KEY.
which is handled here :

https://github.com/Purvanshsingh/creditrisk-poc/blob/cebf08b38301f449566fda25f937b40ce8c65f8b/creditrisk_poc/api_doc/NPLVocab_parser.py#L52-L55

That should probably always work if the input ontology is valid. The peculiar case is if the ontology has a class with an object property linking it to another class that has no data properties. Logically it is fine but it will be implemented as a FK to a table that has no data...

@open-risk open-risk closed this Jul 1, 2021
@open-risk open-risk reopened this Jul 1, 2021
@Purvanshsingh Purvanshsingh merged commit b79cfd5 into HTTP-APIs:main Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Automated script for creating NPL Vocabulary
3 participants