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 service info endpoint #192

Closed
wants to merge 8 commits into from
Closed

Conversation

JaeAeich
Copy link

@JaeAeich JaeAeich commented Jun 9, 2024

fixed - #157

Summary by Sourcery

This pull request adds a new service info endpoint to the TES API, providing comprehensive details about the service. It also includes significant refactoring of the TeskApp class to streamline initialization and updates the deployment configuration to support the new service info settings.

  • New Features:
    • Introduced a new service info endpoint to provide detailed information about the TES service, including its ID, name, type, description, organization, contact URL, documentation URL, creation and update timestamps, environment, version, storage locations, and supported backend parameters.
  • Enhancements:
    • Refactored the TeskApp class to simplify initialization by removing optional parameters and setting default values for configuration file and custom configuration model.
    • Updated the deployment configuration to include custom service info settings.

@JaeAeich JaeAeich changed the base branch from master to main June 9, 2024 09:51

This comment was marked as off-topic.

@JaeAeich JaeAeich changed the base branch from main to feat/baseClasses June 9, 2024 09:52
@JaeAeich
Copy link
Author

JaeAeich commented Jun 9, 2024

@sourcery-ai review

Copy link

sourcery-ai bot commented Jun 9, 2024

🧙 Sourcery is reviewing your pull request!


Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @JaeAeich - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -0,0 +1,55 @@
"""RFC3339 date validator."""
Copy link

Choose a reason for hiding this comment

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

suggestion: Validator class naming

Consider renaming the class RFC3339 to RFC3339Validator for consistency and clarity, especially since the docstring refers to it as RFC3339Validator.

Suggested change
"""RFC3339 date validator."""
"""RFC3339Validator date validator."""

Choose a reason for hiding this comment

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

you should rename this with the purpose this validator serves or consider it in the deinition.

@@ -0,0 +1,35 @@
"""Base class for TES API pydantic models."""
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Validator import

The import for RFC2386 should be corrected to RFC2368 to match the correct RFC for email validation.

Choose a reason for hiding this comment

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

Should we incorporate this?

@@ -0,0 +1,24 @@
"""RFC2386 email validator."""
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Incorrect RFC number

The correct RFC for email validation is RFC 2368, not RFC 2386. Please update the class name and references accordingly.

@@ -0,0 +1,33 @@
"""RFC3986 URL validator."""
Copy link

Choose a reason for hiding this comment

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

suggestion: Validator class naming

Consider renaming the class RFC3986 to RFC3986Validator for consistency and clarity, especially since the docstring refers to it as RFC3986Validator.

Suggested change
"""RFC3986 URL validator."""
"""RFC3986Validator URL validator."""

Copy link

@kushagra189 kushagra189 left a comment

Choose a reason for hiding this comment

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

Please incorporate the comments.

deployment/config.yaml Show resolved Hide resolved
"""Base class for the TES API.

This class is an abstract class that defines the common properties and
methods needed by all of the TES API endpoint business logic.
"""

def __init__(self) -> None:

Choose a reason for hiding this comment

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

IMO we should keep a default init.

Copy link
Author

Choose a reason for hiding this comment

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

BaseTeskRequest is implementing ABC, would we initialize super still?

deployment/config.yaml Show resolved Hide resolved
# Get logger instance
logger = logging.getLogger(__name__)

service_info = ServiceInfo()

Choose a reason for hiding this comment

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

Should we define this in the method itself?

Copy link
Author

Choose a reason for hiding this comment

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

If someone keeps hitting this endpoint, why initialise the the obj again and again, either way it is not supposed to change or be that fickel, in that case it makes more sense to give cached result.

PS: The case will be diff when/if we implement post service endpoint.

tesk/api/ga4gh/tes/controllers.py Show resolved Hide resolved
"a different namespace (e.g. your organization's reverse domain name)."
),
)
artifact: Literal['tes'] = Field(

Choose a reason for hiding this comment

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

Why Literal?

Copy link
Author

Choose a reason for hiding this comment

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

because its "Literal"ly just tes in the specs. It mentions enum there, but since there wont be anything but tes why not use literal.

r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+' # domain part 1
r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain part 2
r'localhost|' # localhost...

Choose a reason for hiding this comment

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

is this correct?

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 tested with limited set of URLs and that seems to be correct afaik 😭, maybe better use the pydantic type HttpURL.

from tesk.tesk_app import TeskApp


class BaseServiceInfoRequest(BaseTeskRequest):

Choose a reason for hiding this comment

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

Do we really need this? Do you think there is a possibility of multiple input service info request?

Copy link
Author

Choose a reason for hiding this comment

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

yeah this one I don't really need this one specifically but since I will def need similar "interface" in task endpoint for consistency, I implemented interface for service as well.

tesk/api/ga4gh/tes/service_info/service_info.py Outdated Show resolved Hide resolved
@JaeAeich
Copy link
Author

please check #198

@JaeAeich JaeAeich closed this Jun 30, 2024
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