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

[engsys] Migrate to tox4 #30159

Merged
merged 42 commits into from May 23, 2023

Conversation

kdestin
Copy link
Member

@kdestin kdestin commented Apr 30, 2023

Description

This pull request migrates this repository's tox config to be compatible with tox 4. Major changes include:

  • All references to tox-monorepo were removed in the repository. tox4 adds native support for the use-case that tox-monorepo enables: --root allows for {toxinidir} to be specified indepedently of the location of tox.ini.
  • Documentation was updated to use tox4-isms: use --root in examples, call out that default values for the config file and root can be set with environment variables, etc...
  • tox_harness.py was updated to use --root when invoking tox
  • A smattering of refactors to tox.ini to clean it up
    • As many paths as possible were re-written relative to repository root. (Uses a local tox plugin (toxfile.py) to compute the repository root)
    • Deprecated and/or unnecessary config keys were updated.

This PR is part of an ongoing effort by the ML team to make azure-sdk-for-python's tooling more convenient for use during local development (Not a high priority workstream): #28785.

Resolves #28267

cc: @scbedd

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

    tox prepends the {env_bin_dir} to $PATH, so commands
    will default to using the virtual environment first.

    See: https://tox.wiki/en/4.4.11/config.html#commands

    One of tox's core maintainers also discourages its use:
      tox-dev/tox#2909 (comment)
    Uses an inline plugin (toxfile.py) to make a computed config
    value avaiable to tox environments.
    {toxinidir} is an alias for {tox_root}, but {tox_root} is:
      * More clear: {tox_root} isn't necessarily where the ini file is
      * Shorter
    --ignore-installed can break a python installation if multiple
    conflicting versions of a package are installed
    platform = linux: linux
               macos: darwin
               windows: win32

    Setting the above in the base environment has no effect:
        * None of the environments have {linux,macos,windows} in the
          name, so the platform config is always empty.
    tox4 natively solves what `tox-monorepo` was written to solve:
    `--root` lets you set `toxinidir` independently of the config
    file in use.

    4.4.11 was chosen as the cutoff since it was the first release to
    include a fix to `--root` that prevented `{work_dir}` from being
    changed when `{toxinidir}` was changed by `--root`.

    `tox-monorepo` should no longer be needed
    * References to tox-monorepo were removed
    * Replaced discussion of `tox -l` with tox4's `tox list`
    * Updated examples to use `--root`
    * TOX_CONFIG_DIR can be used to permanently set --conf
    * TOX_ROOT_DIR can be used to permanently set --root
@github-actions github-actions bot added VideoAnalyzer Azure Video Analyzer Media labels Apr 30, 2023
@kdestin kdestin removed VideoAnalyzer Azure Video Analyzer Media labels Apr 30, 2023
@scbedd
Copy link
Member

scbedd commented May 10, 2023

Another thing that's visible is that we are seeing timeouts again when installing.
There has to be something that isn't shared properly in the new tox, which is why we see these really super long timeouts in CI. It's a deadlock between two tox environments running in parallel :(

Do you happen to know what the issue was the last time you dealt with this?

It was a long painful process of nailing down every single possible file lock. That's why you notice stuff like a different pip cache directory for each tox environment, etc.

eng/regression_test_tools.txt Outdated Show resolved Hide resolved
eng/regression_tools.txt Outdated Show resolved Hide resolved
@scbedd
Copy link
Member

scbedd commented May 11, 2023

We're v close now! Just FYI we won't be merging this even if it's green until next week at the least. We're in a release window right now and I don't like to introduce any eng code changes around this time.

Remaining issues and additional checks before we can merge this:

  • Resolve autorest - pr failing on this PR
    • I think we will be able to resolve this by a simple update from upstream once we iron out everything else.
    • PR Already Submit By @iscai-msft
      • Gonna get this merged to resolve that failure.
  • Check that our regression tests will still run. Entrypoint. Implementation.
  • Run nightly alpha version (storage,core,ml) to confirm everything works there. (internal build, SetDevVersion=true, run)
    • Storage
    • Core
    • ML
    • These are all running with Run.Regression=true and SetDevVersion=true
  • Resolve failing coverage
    • I'm looking at this right now, it's probably a fix where we don't need to apply our fix .coverage files anymore
  • Why is videoanalyzer CI timing out so badly? Fix it!
    • I believe I added a commit that resolves this. azure-media-videoanalyzer-edge dev_requirements included tox>4.4.X, which was causing us to attempt to install tox within a tox venv. Pretty clear that's where the massive timeout was coming from.

@kdestin
Copy link
Member Author

kdestin commented May 12, 2023

We're v close now!

Nice!

Just FYI we won't be merging this even if it's green until next week at the least. We're in a release window right now and I don't like to introduce any eng code changes around this time.

Works for me, there's no rush on my end.

  • Why is videoanalyzer CI timing out so badly? Fix it!

    • I believe I added a commit that resolves this. azure-media-videoanalyzer-edge dev_requirements included tox>4.4.X, which was causing us to attempt to install tox within a tox venv. Pretty clear that's where the massive timeout was coming from.

Wow, I would've imagined that it trivially satisfies that installation requirement (I think tox bootstraps itself into a virtualenv, but I may be wrong).

@scbedd
Copy link
Member

scbedd commented May 12, 2023

Wow, I would've imagined that it trivially satisfies that installation requirement (I think tox bootstraps itself into a virtualenv, but I may be wrong).

At the end of the day it's just using pip to install within the environment, so there is no place to prevent that install loop from going wrong. I'm almost certain this is related to a file lock someplace. Regardless, cutting that entry resolves the issue. I think we're probably ok on the parallel access problem I thought may be present.

@scbedd
Copy link
Member

scbedd commented May 12, 2023

I will run regression and nightly alpha checks tomorrow, then we will be in the clear to merge this next week! 🚀 🚀 🚀 🚀 🚀 🚀 🚀 🚀

@scbedd
Copy link
Member

scbedd commented May 12, 2023

@kdestin We are GREEN! Regress tests + nightly alpha versions all seem to be working appropriately!

I'm a bit disturbed by the consistent credscan stack overflow, but I don't think that's related to this PR at all. Let's see where releases are come monday, then make an announcement and merge it!

Thank you so much for all the effort on this @kdestin ! This is a gigantic necessary contribution that is not at all fun to slog through 👍

@scbedd
Copy link
Member

scbedd commented May 15, 2023

@kdestin We are GREEN! Regress tests + nightly alpha versions all seem to be working appropriately!

I'm a bit disturbed by the consistent credscan stack overflow, but I don't think that's related to this PR at all. Let's see where releases are come monday, then make an announcement and merge it!

Thank you so much for all the effort on this @kdestin ! This is a gigantic necessary contribution that is not at all fun to slog through 👍

On detailed review over the weekend, I found one last issue.

We have one outstanding issue with coverage not properly generating. I think it's simply because we need to install the packages that we generate coverage for, but I'm going to figure that out.

Remember, package is installed when we GENERATE the coverage, but I think we now need to ensure that its present when we COMBINE and PUBLISH this report. I think that's the issue at play.

@scbedd
Copy link
Member

scbedd commented May 18, 2023

Ok @kdestin I think we are ready to rock! :shipit: :shipit: :shipit: :shipit:

Barring a notification to the internal team, this is ready to squash merge!

@scbedd
Copy link
Member

scbedd commented May 22, 2023

/azp run python - core - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@lmazuel lmazuel left a comment

Choose a reason for hiding this comment

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

Thanks again @kdestin !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team.
Projects
Development

Successfully merging this pull request may close these issues.

Update tox-monorepo for tox 4.0, update CI to consume tox 4.0
5 participants