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

feat: Add client for SystemLink jobs API #85

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

ganesh-nithin
Copy link

@ganesh-nithin ganesh-nithin commented Nov 29, 2024

What does this Pull Request accomplish?

This PR adds client methods for job group of Systems endpoints with integration tests for these endpoints

Why should this Pull Request be merged?

This System client (job) for System Management endpoints will improve user interactivity with those endpoints

What testing has been done?

Automated integration tests are included.

API Link: Swagger-link

Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
@ganesh-nithin ganesh-nithin marked this pull request as ready for review November 29, 2024 07:34
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
assert len(response) == 1

def test__list_jobs__Invalid_system_id__fails(self, client: SystemClient):
with pytest.raises(Exception):
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
with pytest.raises(Exception):
with pytest.raises(ApiException):

reflect this in other places.

Copy link
Author

Choose a reason for hiding this comment

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

Modified & reflected in other places.

Query("take"),
],
)
def list_jobs(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def list_jobs(
def list_jobs_paged(

Copy link
Author

Choose a reason for hiding this comment

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

Skipping the suggestion as list jobs are not paged as it don't have continuation token property.

...

@post("query-jobs")
def query_jobs(self, query: models.QueryJobsRequest) -> models.QueryJobsResponse:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def query_jobs(self, query: models.QueryJobsRequest) -> models.QueryJobsResponse:
def query_jobs_paged(self, query: models.QueryJobsRequest) -> models.QueryJobsResponse:

Copy link
Author

Choose a reason for hiding this comment

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

Skipping the suggestion as query jobs are not paged as it don't have continuation token property.

The list of jobs that matched the criteria.

Raises:
ApiException: if unable to communicate with the System Service
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ApiException: if unable to communicate with the System Service
ApiException: if unable to communicate with the ``/nisysmgmt`` Service

Copy link
Collaborator

Choose a reason for hiding this comment

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

Update in all other places

Copy link
Author

Choose a reason for hiding this comment

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

I have updated it, & reflected the same in other places.

class CreateJobRequest(JobConfig):
"""Model for create job request."""

metadata: Optional[Dict[str, Any]] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update it with actual properties..

Copy link
Author

Choose a reason for hiding this comment

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

I have updated it. As CreateJobResponse is extended from CreateJobRequest, properties will be updated in it.

from nisystemlink.clients.core._uplink._json_model import JsonModel


class HttpError(JsonModel):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ApiError class from uplink core module instead of creating new one.

Copy link
Author

Choose a reason for hiding this comment

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

I have updated it, & reflected the same in other places.

error: Optional[HttpError] = None
"""Represents the standard error structure."""

data: Optional[List[str]] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change the datatype of the data property.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the property.

@pytest.mark.integration
@pytest.mark.enterprise
class TestSystemClient:
def test__create_job__succeeds(
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we update test names with proper details?

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the tests.

Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
@@ -0,0 +1,10 @@
from ._job import Job, JobState
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
from ._job import Job, JobState
from ._job import Job, JobState, JobConfig, JobResult


def test__list_jobs__invalid_system_id(self, client: SystemClient):
response = client.list_jobs(system_id="Invalid_system_id")
assert response == []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert response == []
assert len(response) == 0

@Madhan-Reddy-ni Madhan-Reddy-ni added the enhancement New feature or request label Dec 3, 2024
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
@santhoshramaraj
Copy link
Member

santhoshramaraj commented Dec 5, 2024

@ganesh-nithin , please update field/arg names to be Pythonic, for example id or job_id based on context instead of jid

@ganesh-nithin ganesh-nithin marked this pull request as draft December 6, 2024 09:28
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
@ganesh-nithin ganesh-nithin marked this pull request as ready for review December 11, 2024 17:20
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Signed-off-by: Ganesh Nithin <sarvabhotla.g@solitontech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants