mintproject / wcm

WINGS Component Manager
Apache License 2.0
1 stars 2 forks source link

Use model catalog api python client #28

Open mosoriob opened 4 years ago

mosoriob commented 4 years ago

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

dhruvp-8 commented 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

dgarijo commented 4 years ago

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 .

dhruvp-8 commented 4 years ago

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)

mosoriob commented 4 years ago

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?

dgarijo commented 4 years ago

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.

dhruvp-8 commented 4 years ago

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.

maurya-rohit commented 4 years ago

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:

  1. The variable names were same in yaml and api whereas we have to manually create an object for python api client where hasInput was declared as has_input. This added extra unnecessary effort.
  2. Also, since we have to update the yaml file in to insert the ids for the newly generated data, it was easier to keep the whole data in json, since both are easily interchangeable.
  3. We are doing authentication when you configure mint-api.
  4. It was adding additional layer which was more difficult to maintain while we can directly use the api. As dhruv mentioned publishing and validation is different, so if there is any error it should be detected during the validation which was the point of creating two yaml so that we can validate easily.