Skip to content

Conversation

@FedericoNegri
Copy link
Contributor

@FedericoNegri FedericoNegri commented Aug 19, 2022

Example of new syntax:

from ansys.rep.client import Client
from ansys.rep.client.jms import JmsApi, ProjectApi
from ansys.rep.client.auth import AuthApi

client = Client("https://localhost:8443/rep", "repadmin", "repadmin")

auth_api = AuthApi(client)
users = auth_api.get_users()

jms_api = JmsApi(client)
project = jms_api.get_project(name="my_project")
project_api = ProjectApi(client, project.id)
jobs = project_api.get_jobs()

All tests and example are updated. There are some open todo items (related to this PR):

  • Figure out how to use KeycloakAdmin with existing tokens, to avoid storing the password. Might need a PR to https://github.com/marcospereirampj/python-keycloak --> agreed to postpone to a follow-up PR
  • Adjust project restore and project.copy_jobs
  • Make sure the test for algorithms and selections passes once the API changes in the backend are in

The 2 current test failures are due to the Auth issue above
failing_tests

@ojkoenig ojkoenig self-requested a review August 19, 2022 20:10
@ojkoenig ojkoenig marked this pull request as ready for review August 19, 2022 20:10
Copy link
Contributor

@ojkoenig ojkoenig left a comment

Choose a reason for hiding this comment

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

Checked out your branch and played with an example. I am happy with the changes.
I understand the needed backend change to move selections endpoint to projects/my_proj/job_selections and can help on that if needed.
But what backend change you need on algorithm?

Does the merge of this PR depend on a possible keycloak-python change you mention?

@FedericoNegri
Copy link
Contributor Author

Checked out your branch and played with an example. I am happy with the changes. I understand the needed backend change to move selections endpoint to projects/my_proj/job_selections and can help on that if needed. But what backend change you need on algorithm?

Does the merge of this PR depend on a possible keycloak-python change you mention?

@ojkoenig Thanks for reviewing.

No backend changes needed for algorithms - the test for algorithms hits the selections endpoint as well and therefore it's currently failing, I only need to make sure it passes once the backend changes for selections are in.

With respect to KeyCloak: currently the Auth API (get\create\update\delete users) is disabled because it would require storing the password inside our Client object. That's because we rely on the KeycloakAdmin object from the python-keycloak package, which doesn't expose authenticating via tokens, only via username+password or client_id+client_secret_key. However, the KeyCloak API itself does support our workflow and I already verified it would work. My proposal is to merge the current state with the disabled Auth API, work on a PR to the python-keycloak repo (do I need approval?) and then re-enable it.

project_api = ProjectApi(client, proj.id)

cwd = os.path.dirname(__file__)
example_dir = os.path.join(cwd, "..", "..", "examples", "mapdl_motorbike_frame")

Choose a reason for hiding this comment

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

I'd upload any examples that cannot or should not be included in repository to https://github.com/pyansys/example-data and implement a basic downloader as in https://github.com/pyansys/pymapdl/blob/main/src/ansys/mapdl/core/examples/downloads.py or using pooch

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point, I agree we should do that eventually. Jonathan did the same already for pyAssembly.

@ojkoenig
Copy link
Contributor

My proposal is to merge the current state with the disabled Auth API, work on a PR to the python-keycloak repo (do I need approval?) and then re-enable it.

@FedericoNegri : Sounds like a good plan to me.

@github-actions github-actions bot added dependencies Related with project dependencies documentation Improvements or additions to documentation labels Aug 21, 2022
@FedericoNegri FedericoNegri merged commit b03238d into main Aug 21, 2022
@FedericoNegri FedericoNegri deleted the fnegri/project_api_common_client branch August 22, 2022 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Related with project dependencies documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants