Open mosoriob opened 4 years ago
Actually, we had talked to @dgarijo regarding the use of model catalog python api client. Apparently I need to bind the data into class variables in the python api client in comparison to directly sending the data in JSON format using the requests package which is more convenient.
PS: We do validate the data before sending them in JSON using requests
Hi Dhruv, Maybe I am missing something, but you should use the model catalog API, as you are inserting information in the model catalog. Daniel
El mié., 8 ene. 2020 12:34 p. m., Dhruv notifications@github.com escribió:
Actually, we had talked to @dgarijo https://github.com/dgarijo regarding the use of model catalog python api client. Apparently I need to bind the data into class variables in the python api client in comparison to directly sending the data in JSON format using the requests package which is more convenient.
PS: We do validate the data before sending them in JSON using requests
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mintproject/wcm/issues/28?email_source=notifications&email_token=AALTIGVJ5KJNQEN7537PLYLQ4XB5TA5CNFSM4KDNAQF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIMHPRA#issuecomment-572028868, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALTIGRLTXEOBN27DF7P2YDQ4XB5TANCNFSM4KDNAQFQ .
Correct Daniel, we are using the model catalog API for inserting the data but we are not using model catalog python api package (https://github.com/mintproject/model-catalog-python-api-client) to do this, instead we are using requests package (as we can directly send the data in json format)
Since you don't use the client, you must handle the errors, configuration, and authentication. Also, you must maintain the code (new releases).
What are the benefits of a built-in solution?
I agree with @sirspock; why making your life more complicated? The code will be more difficult to maintain if we add new changes to the API.
Initially I was using the python client to do this stuff but the problem I was facing with that is I have to manually go and set the value of each property which is cumbersome. For eg: If I want to use Dataset Specification. I will have to manually insert the value of each property and if some properties are optional then also I have to set them to null(for string) or [] (For array). There are many properties inside a single object so setting each of their properties manually is not a good option. Whereas using requests we can directly send JSON (not set properties which are optional). Moreover, we perform the validation of YAML before sending the data so in that way there should not be any problems.
Just to add, we initially tried both methods and I think we consulted with @dgarijo if we can directly use the API, and you mentioned it is okay as python api client itself uses api in its core, it was for the user to publish any data. Moreover, it was convenient to use the api directly for following reason:
Why don't you use the model catalog api?
https://github.com/mintproject/model-catalog-python-api-client
https://github.com/mintproject/wcm/blob/fcd7b3d5822368319be2fadbb84709662f5b287b/src/wcm/_has_grid.py#L10