Skip to content

Conversation

@Borda
Copy link
Collaborator

@Borda Borda commented Nov 25, 2020

What does this PR do?

drop tricky try/catch. form optional imports, @awaelchli
resolves #2266

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified; Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases.

Did you have fun?

Make sure you had fun coding 🙃

@Borda Borda added feature Is an improvement or enhancement refactor 3rd party Related to a 3rd-party labels Nov 25, 2020
@Borda Borda added this to the 1.1 milestone Nov 25, 2020
@Borda Borda requested a review from awaelchli November 25, 2020 21:51
@Borda
Copy link
Collaborator Author

Borda commented Nov 25, 2020

@awaelchli any idea how it is possible that the package is found so XXXX_AVAILABLE is true. but the import fails?

@Borda
Copy link
Collaborator Author

Borda commented Nov 25, 2020

@awaelchli it seems that the conditional import does not work, it is imported even inside the if statement... :/

@akihironitta
Copy link
Contributor

@Borda Seems _module_available needs some fix.
I ran the following script:

import importlib

def _module_available(module_path: str) -> bool:
    """Testing if given module is avalaible in your env
    >>> _module_available('system')
    True
    >>> _module_available('bla.bla')
    False
    """
    mods = module_path.split('.')
    assert mods, 'nothing given to test'
    # it has to be tested as per partets
    for i in range(1, len(mods)):
        module_path = '.'.join(mods[:i])
        if importlib.util.find_spec(module_path) is None:
            return False
    return True

print(_module_available("asdf"))
print(_module_available("asdf.asdf"))

and encountered the following unexpected behaviour...

True
False

@Borda
Copy link
Collaborator Author

Borda commented Nov 26, 2020

@Borda Seems _module_available needs some fix.

Great catch, I am adding also some more test for the func... fix in #4871

@Borda Borda marked this pull request as ready for review November 26, 2020 12:08
@Borda Borda mentioned this pull request Nov 26, 2020
11 tasks
@Borda Borda removed the help wanted Open to be worked on label Nov 26, 2020
@Borda
Copy link
Collaborator Author

Borda commented Nov 26, 2020

@tgaddair mind have a look at why the Horovod tests are failing?

@Borda Borda mentioned this pull request Nov 26, 2020
11 tasks
@Borda Borda changed the title refactor imports of optional dependencies refactor imports of optional dependencies [WIP] Nov 26, 2020
This was referenced Nov 26, 2020
@Borda
Copy link
Collaborator Author

Borda commented Nov 26, 2020

after merging all the partial PRs this remain only for Horovod

@Borda Borda added the priority: 1 Medium priority task label Nov 26, 2020
@Borda Borda force-pushed the refactor/imports-extras branch from bf5cb91 to 6dfe510 Compare November 27, 2020 00:11
@Borda Borda changed the title refactor imports of optional dependencies [WIP] refactor imports of optional dependencies Nov 27, 2020
@Borda Borda added the help wanted Open to be worked on label Nov 27, 2020
@Borda Borda force-pushed the refactor/imports-extras branch from ae0c9c2 to ff9e7cd Compare November 27, 2020 17:13
@codecov
Copy link

codecov bot commented Nov 27, 2020

Codecov Report

Merging #4859 (b88d6f2) into master (02ac3ab) will decrease coverage by 0%.
The diff coverage is 80%.

@@          Coverage Diff           @@
##           master   #4859   +/-   ##
======================================
- Coverage      93%     93%   -0%     
======================================
  Files         124     124           
  Lines        9302    9295    -7     
======================================
- Hits         8615    8608    -7     
  Misses        687     687           

@Borda Borda force-pushed the refactor/imports-extras branch 2 times, most recently from 16b7e22 to 66aaf34 Compare November 27, 2020 19:34
@Borda Borda force-pushed the refactor/imports-extras branch from 66aaf34 to 3f00512 Compare November 27, 2020 20:49
@Borda
Copy link
Collaborator Author

Borda commented Nov 27, 2020

the TPU and GPU #4884 failing is unrelated to this PR

RuntimeError: Failed precondition: From /job:tpu_worker/replica:0/task:0:
2 root error(s) found.
  (0) Failed precondition: Expected comparison type FLOAT or TOTALORDER.
actual: UNSIGNED
operand: f32[32,10]

	 [[{{node XRTCompile}}]]
  (1) Failed precondition: Expected comparison type FLOAT or TOTALORDER.
actual: UNSIGNED
operand: f32[32,10]

	 [[{{node XRTCompile}}]]
	 [[XRTCompile_G6]]

cc: @zcain117

@Borda Borda added the ready PRs ready to be merged label Nov 27, 2020
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LTGM !

@Borda Borda merged commit 3976db5 into master Dec 4, 2020
@Borda Borda deleted the refactor/imports-extras branch December 4, 2020 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3rd party Related to a 3rd-party feature Is an improvement or enhancement help wanted Open to be worked on priority: 1 Medium priority task ready PRs ready to be merged refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Exception Handling

6 participants