GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Import error for cloud_profiler by mkovalski · Pull Request #869 · googleapis/python-aiplatform

Conversation

@mkovalski

@mkovalski mkovalski commented Nov 29, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Circular imports involving absolute imports with binding a submodule to a name was not supported in python 3.6, as documented here. Needed to update import.

  • Import initializer without alias
  • Move the ImportError to the tf profiler module.

Fixes #867

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mkovalski
fix import error involving absolute imports: bpo-30024
1368556
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 29, 2021
@product-auto-label product-auto-label Bot added the api: aiplatform Issues related to the AI Platform API. label Nov 29, 2021
mkovalski added 4 commits November 29, 2021 20:32
@mkovalski
fix: import error involving absolute imports: fixes googleapis#867
7d8ef46
@mkovalski
Merge branch 'training_utils_fix' of github.com:mkovalski/python-aipl…
58c5519
…atform into training_utils_fix
@mkovalski
fix: Move the import checks to tf profiler module
d76cef1
@mkovalski
fix: remove unnecessary importlib mock from tf_profiler test
91ef8d5
@mkovalski
mkovalski requested a review from sasha-gitg November 30, 2021 00:20
@mkovalski
mkovalski marked this pull request as ready for review November 30, 2021 00:58
sasha-gitg
sasha-gitg requested changes Nov 30, 2021
View reviewed changes
Comment thread google/cloud/aiplatform/training_utils/cloud_profiler/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mkovalski
fix: add werkzeug to profiler requirements and add additional missing…
97d41d4
… module to test
@mkovalski
mkovalski requested review from a team and sasha-gitg November 30, 2021 17:57
sasha-gitg
sasha-gitg requested changes Nov 30, 2021
View reviewed changes
Comment thread setup.py Outdated
profiler_extra_require = ["tensorboard-plugin-profile", "tensorflow >=2.4.0"]
profiler_extra_require = [
"tensorboard-plugin-profile",
"werkzeug",

@sasha-gitg sasha-gitg Nov 30, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please add constraints on this version. Also preferable on TB plugin profile above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mkovalski mkovalski Dec 1, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/aiplatform/training_utils/cloud_profiler/plugins/tensorflow/tf_profiler.py Outdated

try:
from tensorboard_plugin_profile.profile_plugin import ProfilePlugin
from werkzeug import Response

@sasha-gitg sasha-gitg Nov 30, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

initializer.py imports werkzeug before importing tf_profiler: https://github.com/googleapis/python-aiplatform/blob/main/google/cloud/aiplatform/training_utils/cloud_profiler/initializer.py#L21

Recommend catching on all optional imports or walking through all the imports to determine when they are first imported.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mkovalski mkovalski Dec 1, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done, I went with catching the imports at where they were first imported. The tests should catch the verbiage as well.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/aiplatform/test_cloud_profiler.py Outdated
for mock_module in ["tensorboard_plugin_profile.profile_plugin", "werkzeug"]:
with self.subTest():
with mock.patch.dict("sys.modules", {mock_module: None}):
self.assertRaises(ImportError, reload, tf_profiler)

@sasha-gitg sasha-gitg Nov 30, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should this test importing cloud_profiler as that's the prescribed usage?

Also, may want to use the context manager to get the exception object and ensure the raised exception includes the intended verbiage.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mkovalski mkovalski Dec 1, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mkovalski and others added 3 commits December 1, 2021 17:07
@mkovalski
fix: version requirements on setup.py, catching exception and checkin…
b9353a8
…g verbiage in error message
@mkovalski
setup using cloud-profiler rather than cloud_profiler
54e3839
@sasha-gitg
Merge branch 'main' into training_utils_fix
728d559
@mkovalski
mkovalski requested a review from sasha-gitg December 1, 2021 17:36
sasha-gitg
sasha-gitg reviewed Dec 1, 2021
View reviewed changes
Comment thread google/cloud/aiplatform/training_utils/cloud_profiler/plugins/tensorflow/tf_profiler.py
from urllib import parse
from werkzeug import Response

from google.cloud.aiplatform.tensorboard.plugins.tf_profiler import profile_uploader

@sasha-gitg sasha-gitg Dec 1, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It looks like this would import Tensorflow and not be caught.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mkovalski added 3 commits December 1, 2021 17:54
@mkovalski
fix: Add tensorflow to module check
71a2c06
@mkovalski
Merge branch 'training_utils_fix' of github.com:mkovalski/python-aipl…
780cd00
…atform into training_utils_fix
@mkovalski
fix: Adding tensorflow and tensorboard as top level import for catchi…
c3c2c9e
…ng cloud-profiler import errors
sasha-gitg
sasha-gitg approved these changes Dec 1, 2021
View reviewed changes
@sasha-gitg
sasha-gitg merged commit 0f124e9 into googleapis:main Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sasha-gitg sasha-gitg sasha-gitg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: aiplatform Issues related to the AI Platform API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

The build failed

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mkovalski @sasha-gitg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.