8000 simplify tool responses by hsheth2 · Pull Request #4 · acryldata/mcp-server-datahub · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

simplify tool responses #4

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

Merged
merged 2 commits into from
May 2, 2025
Merged

simplify tool responses #4

merged 2 commits into from
May 2, 2025

Conversation

hsheth2
Copy link
Contributor
@hsheth2 hsheth2 commented May 2, 2025
  • start removing additional fields
  • simplify queries list

@hsheth2 hsheth2 requested a review from Copilot May 2, 2025 22:07
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies tool responses by removing additional fields and streamlining the queries list. Key changes include:

  • Using json.dumps for formatted printing in output functions.
  • Simplifying the GraphQL response by narrowing the "subjects" field to unique dataset urns.
  • Removing unneeded intermediate variables for cleaner code flow.
Files not reviewed (2)
  • src/mcp_server_datahub/gql/entity_details.gql: Language not supported
  • src/mcp_server_datahub/gql/queries.gql: Language not supported

Comment on lines +188 to 196
updated_subjects: OrderedSet[str] = OrderedSet()
for subject in query["subjects"]:
with contextlib.suppress(KeyError):
updated_subjects.add(subject["dataset"]["urn"])
query["subjects"] = list(updated_subjects)

return result


Copy link
Preview
Copilot AI May 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider extracting the logic for deduplicating subjects into a separate helper function to improve readability and maintainability.

Suggested change
updated_subjects: OrderedSet[str] = OrderedSet()
for subject in query["subjects"]:
with contextlib.suppress(KeyError):
updated_subjects.add(subject["dataset"]["urn"])
query["subjects"] = list(updated_subjects)
return result
query["subjects"] = _deduplicate_subjects(query["subjects"])
return result
def _deduplicate_subjects(subjects: list[dict]) -> list[str]:
"""
Deduplicates the dataset URNs from the subjects list.
Args:
subjects (list[dict]): The list of subjects containing dataset information.
Returns:
list[str]: A deduplicated list of dataset URNs.
"""
updated_subjects: OrderedSet[str] = OrderedSet()
for subject in subjects:
with contextlib.suppress(KeyError):
updated_subjects.add(subject["dataset"]["urn"])
return list(updated_subjects)

Copilot uses AI. Check for mistakes.

@hsheth2 hsheth2 merged commit 168408f into main May 2, 2025
1 check passed
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.

1 participant
0