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

UIP-47: update clients #3556

Merged
merged 3 commits into from
Jun 7, 2024
Merged

UIP-47: update clients #3556

merged 3 commits into from
Jun 7, 2024

Conversation

ialarmedalien
Copy link
Collaborator

@ialarmedalien ialarmedalien commented Jun 5, 2024

Description of PR purpose/changes

Commit 1:

  • uses full paths for py modules instead of relative (commit 1)

Commit 2:

  • updates the clients where appropriate using kb-sdk install <client_name>
  • moves all the clients that the narrative uses to an installed_clients directory and removes all the duplicated base client.py files.
  • removes old directories

Commit 3:

  • updates some python deps that dependabot chose not to reveal until yesterday

Jira Ticket / Issue

Related Jira ticket: https://kbase-jira.atlassian.net/browse/UIP-47

  • Added the Jira Ticket to the title of the PR (e.g. DATAUP-69 Adds a PR template)

Testing Instructions

  • Details for how to test the PR:
  • Tests pass locally and in GitHub Actions
  • Changes available by spinning up a local narrative and navigating to X to see Y

Dev Checklist:

  • My code follows the guidelines at https://sites.google.com/lbl.gov/trussresources/home?authuser=0
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • (JavaScript) I have run Prettier and ESLint on changed code manually or with a git precommit hook
  • (Python) I have run Ruff format and check on changed Python code manually or with a git precommit hook
  • Any dependent changes have been merged and published in downstream modules

Updating Version and Release Notes (if applicable)

N/A

@ialarmedalien ialarmedalien requested a review from briehl June 5, 2024 16:30
@ialarmedalien ialarmedalien self-assigned this Jun 5, 2024
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the changes in this file are due to running kb-sdk install catalog - the client has been updated since whenever this file was last touched.

@@ -0,0 +1,94 @@
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

from a freshly generated kbase SDK module

except ImportError:
from urlparse import urlparse as _urlparse # py2

import json
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is actually from a freshly-generated KBase sdk app with some typing stuff added.

Comment on lines +5 to +9
from biokbase.installed_clients.CatalogClient import Catalog
from biokbase.installed_clients.execution_engine2Client import execution_engine2
from biokbase.installed_clients.NarrativeMethodStoreClient import NarrativeMethodStore
from biokbase.installed_clients.ServiceClient import Client as ServiceClient
from biokbase.installed_clients.WorkspaceClient import Workspace
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all clients now in the installed_clients folder

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 97.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 29.70%. Comparing base (f56890d) to head (aa67a64).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3556      +/-   ##
===========================================
+ Coverage    29.69%   29.70%   +0.01%     
===========================================
  Files          496      496              
  Lines        50444    50444              
===========================================
+ Hits         14977    14984       +7     
+ Misses       35467    35460       -7     
Files Coverage Δ
src/biokbase/auth.py 100.00% <100.00%> (ø)
src/biokbase/narrative/clients.py 100.00% <100.00%> (ø)
src/biokbase/narrative/common/exceptions.py 68.75% <100.00%> (+1.00%) ⬆️
src/biokbase/narrative/common/kblogging.py 82.67% <100.00%> (-0.27%) ⬇️
src/biokbase/narrative/common/narrative_logger.py 100.00% <100.00%> (ø)
src/biokbase/narrative/common/narrative_ref.py 95.12% <100.00%> (-0.12%) ⬇️
src/biokbase/narrative/common/url_config.py 80.76% <100.00%> (ø)
...rc/biokbase/narrative/contents/kbasecheckpoints.py 84.61% <100.00%> (ø)
src/biokbase/narrative/contents/kbasewsmanager.py 26.63% <100.00%> (ø)
src/biokbase/narrative/contents/narrativeio.py 30.45% <100.00%> (-0.52%) ⬇️
... and 7 more

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c1a4a7...aa67a64. Read the comment docs.

"""Retrieve the client for a KBase service."""
return __init_client(client_name, token=token)


def __init_client(client_name, token=None):
@cache
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cache the clients

@@ -9,8 +9,8 @@
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this script and its test even worth keeping any more?

Copy link
Member

Choose a reason for hiding this comment

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

I hope not!

Copy link
Member

Choose a reason for hiding this comment

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

It was really used to notify users who had py2 code in their narratives way back before some major Python / IPython version switchover to make those fail. I think it hit single-digits of non-KBase-staff.

@@ -12,8 +12,8 @@
import sys
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is this script still a going concern?

Copy link
Member

Choose a reason for hiding this comment

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

No, I don't think so. We should put it somewhere for reference, but it doesn't need to be maintained.

+ "&fields=token"
)
ret = _requests.post(auth_svc, data=body, allow_redirects=True)
body = "user_id=" + quote(user_id) + "&password=" + quote(password) + "&fields=token"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

requests.utils.quote is just a wrapper around url lib.parse.quote, so use the latter as the former has been deprecated.


from biokbase.workspace.baseclient import ServerError
from biokbase.installed_clients.baseclient import ServerError
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new location for the base client file for importing ServerErrors from

from biokbase.workspace.baseclient import ServerError

from .exceptions import WorkspaceError
from biokbase.narrative.common.exceptions import ServerError, WorkspaceError
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

get server errors from the kbase exceptions file so that if (for whatever reason) the ServerErrors got moved, the import statement in exceptions.py could be updated and nothing else would need to be touched.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, that's the right way.

adding some python updates that didn't make it into the previous PR
updating that accursed release notes file
Copy link

sonarcloud bot commented Jun 5, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarCloud

Copy link
Member

@briehl briehl left a comment

Choose a reason for hiding this comment

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

Nice work on the consolidation and updates.

from biokbase.workspace.baseclient import ServerError

from .exceptions import WorkspaceError
from biokbase.narrative.common.exceptions import ServerError, WorkspaceError
Copy link
Member

Choose a reason for hiding this comment

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

Yup, that's the right way.

@@ -12,8 +12,8 @@
import sys
Copy link
Member

Choose a reason for hiding this comment

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

No, I don't think so. We should put it somewhere for reference, but it doesn't need to be maintained.

@@ -9,8 +9,8 @@
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
Copy link
Member

Choose a reason for hiding this comment

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

I hope not!

@@ -9,8 +9,8 @@
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
Copy link
Member

Choose a reason for hiding this comment

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

It was really used to notify users who had py2 code in their narratives way back before some major Python / IPython version switchover to make those fail. I think it hit single-digits of non-KBase-staff.

@ialarmedalien ialarmedalien merged commit b401562 into develop Jun 7, 2024
7 of 10 checks passed
@ialarmedalien ialarmedalien deleted the update_clients branch June 7, 2024 12:43
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