-
Notifications
You must be signed in to change notification settings - Fork 0
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
#62 MV Link generation from IQS client & API call #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, not bad!
I do have a number of questions and comments though, let us discuss them.
if url_provider(dict_or_attribute_value['element']) is not None: # maybe we should set url param to None - else | ||
setattr(recognized, 'url', url_provider(dict_or_attribute_value['element'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Why was simple field assignment replaced by
setattr
? -
Will there be more than one URL provider (e.g. open in MV, open in Cameo Collab, open in Desktop Tool, etc.)?
If yes, then they will just trumple over each other, and the last one in the list will overwrite the other URLs.
I think if you truly want extensibility here, there you should allow multiple URLs assigned to a single element. -
Also, if there are multiple link providers, we will need a way to distinguish these links on the UI (e.g "Open in Desktop App", "Open in Model Viewer", etc.), so each url provider entry should also come with a distinctive label or something.
-
Minor: avoid evaluating
url_provider
twice; save the return value to a local var that you then reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comments!
- There is no
url
field of elements in the case of query execution - Later
url
field can be a list, or a "domain" to "url" map in order to support multiple urls for an element.
At this point it is important to note that in IQS 2021.5.0 (coming in December) will be an API endpoint for providing
links to original service, IncQuery Desktop and Model Viewer. - We will have to enhance the html representation to handle multiple links for an element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In Python, you can just add fields to most objects by simple assignment - is there a reason why it would not work in this case? The last time I tested the original url_provider solution it still worked - but that was long ago, is there a reason the assignment needed to be replaced? Did the generated Python client change in a way that now the protocol data objects are no longer dict-backed?
- Yes, I agree; I think dict would be the especially best. Anyway, either have a single url provider logic hardcoded for the time being, or have it as an extensible list, but then properly handle the list having multiple elements.
- Yes, but that HTML representation is generated here, so it would make sense to have it as part of this PR.
# return dict_or_attribute_value | ||
# else: | ||
# return dict_or_attribute_value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented out older version
@@ -250,7 +248,7 @@ def _monkey_patch_query_execution_response_to_html(self): | |||
param_headers = " ".join(["<th>{}</th> ".format(html.escape(param)) for param in pattern_params]) | |||
match_rows = "\n".join([ | |||
"<tr><th>{}</th>{}</tr>\n".format(row_index," ".join([ | |||
" <td>{}</td>".format(_cell_to_html(match_list[row_index][param])) for param in pattern_params | |||
" <td><a href=\"{}\">{}</a></td>".format(_cell_to_html(match_list[row_index][param]).url, _cell_to_html(match_list[row_index][param])) for param in pattern_params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link.generating logic should be within _cell_to_html
, not here.
Also, what if a given cell is not a model element, and thus has no url? Do we still generate an <a>
tag with empty href
?
_cell_to_html(match_list[row_index][param]).url
Wait, what? Does _cell_to_html
not return a string? Are you really accessing the url
field of a (HTML) string? How does that make sense? Will that ever work? I think there is a copy-past bug here; contrast with _monkey_patch_analysis_result_repr_html
.
req = requests.get(f"http://{root_configuration.host}/internal-api/solution-configuration") | ||
|
||
# Registering MV URL provider, providing links to MV link received from API call above | ||
ext_point.url_providers.append(ext_point.ModelViewerUrlProvider(self, req.json()["modelViewerBaseURL"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a specific reason why we do not use a generated OpenAPI client in python, instead of manual json parsing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal-api
endpoints are not part of the generated client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but then why is this considered internal API, if it is used by clients to prettify their HTML presentation of query results? Does not sound very internal to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We have a demo
label for parts of the API that are not considered stable)
url_providers: List[Callable[[Any], Optional[Any]]] = [] | ||
|
||
class ModelViewerUrlProvider: | ||
def __init__(self, iqs, mv_address=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a statically / globally registered url provider; it should not be aware of the address of the Model Viewer instance. (What if we connect to multiple IncQuery Suite deployments with different addresses)? I would have expected mv_address
information to be encoded in, perhaps, the iqs
instance.
" <td><a href=\"{}\">{}</a></td>".format( | ||
_dict_to_element(argument_value.value).url, | ||
_cell_to_html(_dict_to_element(argument_value.value))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments at query_execution_response_to_html
FIxes #62
Changes: