Skip to content

Add test that import torch doesn't modify global logging state#87629

Closed
zou3519 wants to merge 2 commits intogh/zou3519/560/basefrom
gh/zou3519/560/head
Closed

Add test that import torch doesn't modify global logging state#87629
zou3519 wants to merge 2 commits intogh/zou3519/560/basefrom
gh/zou3519/560/head

Conversation

@zou3519
Copy link
Contributor

@zou3519 zou3519 commented Oct 24, 2022

Stack from ghstack:

Fixes #87626

Also adds the same test for import functorch. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:

  • tested locally; I added logging.basicConfig to torch/__init__.py
    and checked that the test got triggered

Fixes #87626

Also adds the same test for `import functorch`. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:
- tested locally; I added `logging.basicConfig` to `torch/__init__.py`
and checked that the test got triggered

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Oct 24, 2022
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 24, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/87629

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 Failures

As of commit ff1a590:

The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

zou3519 added a commit that referenced this pull request Oct 24, 2022
Fixes #87626

Also adds the same test for `import functorch`. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:
- tested locally; I added `logging.basicConfig` to `torch/__init__.py`
and checked that the test got triggered

ghstack-source-id: 4a7a7a2
Pull Request resolved: #87629
@zou3519 zou3519 added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 24, 2022
@zou3519 zou3519 requested a review from albanD October 24, 2022 22:04
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Sounds good. minor comment about windows

cwd=os.path.dirname(os.path.realpath(__file__)),).decode("utf-8")
self.assertEquals(out, "")

@unittest.skipIf(IS_WINDOWS, "importing torch+CUDA on CPU results in warning")
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to skip since you don't check for warnings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The warning is going to change the stdout/stderr output, right? Then that affects the string we do a comparison with

out = subprocess.check_output(
[sys.executable, "-W", "all", "-c", "; ".join(commands)],
stderr=subprocess.STDOUT,
# On Windows, opening the subprocess with the default CWD makes `import torch`
Copy link
Collaborator

Choose a reason for hiding this comment

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

not needed if windows is skipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(y)

… state"

Fixes #87626

Also adds the same test for `import functorch`. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:
- tested locally; I added `logging.basicConfig` to `torch/__init__.py`
and checked that the test got triggered

[ghstack-poisoned]
zou3519 added a commit that referenced this pull request Oct 25, 2022
Fixes #87626

Also adds the same test for `import functorch`. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:
- tested locally; I added `logging.basicConfig` to `torch/__init__.py`
and checked that the test got triggered

ghstack-source-id: bff2f26
Pull Request resolved: #87629
@zou3519
Copy link
Contributor Author

zou3519 commented Oct 26, 2022

Test failure is unrelated (tbh I can't find the failing test in the log, but I verified test_no_mutate_global_logging_on_import isn't in the log)

@zou3519
Copy link
Contributor Author

zou3519 commented Oct 26, 2022

@pytorchbot merge -f "test failures are unrelated"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Nov 5, 2022
…orch#87629)

Fixes pytorch#87626

Also adds the same test for `import functorch`. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:
- tested locally; I added `logging.basicConfig` to `torch/__init__.py`
and checked that the test got triggered
Pull Request resolved: pytorch#87629
Approved by: https://github.com/albanD
kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
…orch#87629)

Fixes pytorch#87626

Also adds the same test for `import functorch`. Users have complained at
us when we do modify the global logging state, which has happened in the
past.

Test Plan:
- tested locally; I added `logging.basicConfig` to `torch/__init__.py`
and checked that the test got triggered
Pull Request resolved: pytorch#87629
Approved by: https://github.com/albanD
@facebook-github-bot facebook-github-bot deleted the gh/zou3519/560/head branch June 8, 2023 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants