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

modification for reaxflow-workflow-service #70

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Kirankumaraswamy
Copy link
Contributor

No description provided.

@pablo-de-andres
Copy link
Member

Why is this assigned to me? Should I do something, or just review it?

@Kirankumaraswamy
Copy link
Contributor Author

It was to review.

@pablo-de-andres pablo-de-andres removed their assignment Aug 21, 2023
@pablo-de-andres pablo-de-andres self-requested a review August 21, 2023 09:14
@pablo-de-andres
Copy link
Member

since this is dependent on materials-marketplace/standard-app-api#56, it cannot be reviewed until that one is done

@@ -8,6 +8,8 @@
from .base import _MarketPlaceAppBase
from .utils import _decode_metadata, _encode_metadata

DEFAULT_COLLECTION_NAME = "DEFAULT_COLLECTION"
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't the default defined at the Standard app API level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it would be easy to integrate if in case we need a name change for default collection. SInce standardapp requires rebuilding production. But anyway now I think it soesnot make sense to change the name once datasink application is established. I can move it to standard app if needed.

from .base import _MarketPlaceAppBase


class MarketPlaceSystemApp(_MarketPlaceAppBase):
Copy link
Member

Choose a reason for hiding this comment

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

Why aren't these capabilities directly defined in _MarketPlaceAppBase, loke globalSearch or heartbeat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah makes sense. Since there was an additional system level file in standardapp, I added a new one here. I will move them to base.

self, new_transformation: transformation.NewTransformationModel
self,
new_transformation: transformation.NewTransformationModel,
config: dict = None,
Copy link
Member

Choose a reason for hiding this comment

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

The purpose of config is unclear to me, when we already have params. This should be better documented (not inline, but a proper docstring)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To send additional query parameters which are not defined in Marketplace. For example reaxpro-service needs model_name an additional query parameter to create the transformation. Any key values that are passed in config will be send as query parameters to the application by marketplace. An alternative solution can be to send inside the body. I thought sending it as query will make it less restriction at the application side.

Copy link
Member

Choose a reason for hiding this comment

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

I still think needs a proper docstring (so users can see it through contextual help in their IDEs) would be specially benefitial in this instance.

.env_template Outdated
@@ -8,7 +8,9 @@ MP_ACCESS_TOKEN=....
CLIENT_ID="2c791805-ea52-4446-af97-80c0355a73b4"
Copy link
Member

Choose a reason for hiding this comment

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

This client_id should not be fixed

Copy link
Member

Choose a reason for hiding this comment

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

Also, it is not really a client_id, is it? It's the app id. Otherwise, what is the difference to KEYCLOAK_CLIENT_ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keycloak client_id and client_id are different. As per my understanding inorder to validate an user with username and password using keycloak package, we have to use keycloak_client_id "frontend" which is different from the application id.

from requests import Response

from .version import __version__

MP_DEFAULT_HOST = "https://materials-marketplace.eu/"


def configure_token(func):
Copy link
Member

Choose a reason for hiding this comment

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

All these methods should have proper docstrings that can help users, rather than inline comments

Comment on lines 60 to 61
except Exception:
return None
Copy link
Member

Choose a reason for hiding this comment

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

This means all errors will return None, which in your configure_token will trigger an authentication error, right?

  • Are you sure those are all the possible errors? What is keycloak is down, for example?
  • I would handle exceptions properly and propragate when necessary, rather than catching -> convert to None -> raise new exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I catch all exceptions and display a generic message "Authentication failure" along with actual reason for the error. Any error other than authentication will be caught separately and displayed to user.

@@ -55,20 +100,26 @@ def _request(self, op, path, **kwargs) -> Response:
full_url = urljoin(self.marketplace_host_url, path)
return op(url=full_url, **kwargs)

@configure_token
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed for all the methods, or would it suffice to do it at the _request level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I have changed it in latest code.

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.

2 participants