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

[CI] [Core] Prevent Black from erroring while formatting test_resource_demand_scheduler.py #21313

Closed
Tracked by #21311
bveeramani opened this issue Dec 31, 2021 · 0 comments · Fixed by #21322
Closed
Tracked by #21311
Assignees

Comments

@bveeramani
Copy link
Member

bveeramani commented Dec 31, 2021

Ray Component

Core

What happened + What you expected to happen

I ran black python/ray/tests/test_resource_demand_scheduler.py but got the message

error: cannot format python/ray/tests/test_resource_demand_scheduler.py: INTERNA
L ERROR: Black produced different code on the second pass of the formatter.  Ple
ase report a bug on https://github.com/psf/black/issues.  This diff might be hel
pful: /var/folders/gx/t32twm6x54dftn9b2wxcbl100000gn/T/blk_ac9kaaka.log
Oh no! 💥 💔 💥
1 file failed to reformat.

I'm not sure why the error occurs, but it seems to be related to the assertions at the end of test_add_min_workers_nodes(). If we disable formatting on the assertions, we're able to format the rest of the module.

def test_add_min_workers_nodes():
    types = {
        "m2.large": {
            "resources": {
                "CPU": 2
            },
            "min_workers": 50,
            "max_workers": 100,
        },
        "m4.large": {
            "resources": {
                "CPU": 2
            },
            "min_workers": 0,
            "max_workers": 10,
        },
        "gpu": {
            "resources": {
                "GPU": 1
            },
            "min_workers": 99999,
            "max_workers": 99999,
        },
        "gpubla": {
            "resources": {
                "GPU": 1
            },
            "min_workers": 10,
            "max_workers": 0,
        },
    }
    # yapf: disable
    assert _add_min_workers_nodes([],
                                  {},
                                  types, None, None, None) == \
        ([{"CPU": 2}]*50+[{"GPU": 1}]*99999, {"m2.large": 50, "gpu": 99999},
            {"m2.large": 50, "gpu": 99999})

    assert _add_min_workers_nodes([{"CPU": 2}]*5,
                                  {"m2.large": 5},
                                  types, None, None, None) == \
        ([{"CPU": 2}]*50+[{"GPU": 1}]*99999, {"m2.large": 50, "gpu": 99999},
            {"m2.large": 45, "gpu": 99999})

    assert _add_min_workers_nodes([{"CPU": 2}]*60,
                                  {"m2.large": 60},
                                  types, None, None, None) == \
        ([{"CPU": 2}]*60+[{"GPU": 1}]*99999, {"m2.large": 60, "gpu": 99999},
            {"gpu": 99999})

    assert _add_min_workers_nodes([{
        "CPU": 2
    }] * 50 + [{
        "GPU": 1
    }] * 99999, {
        "m2.large": 50,
        "gpu": 99999
    }, types, None, None, None) == ([{
        "CPU": 2
    }] * 50 + [{
        "GPU": 1
    }] * 99999, {
        "m2.large": 50,
        "gpu": 99999
    }, {})

    assert _add_min_workers_nodes([], {}, {"gpubla": types["gpubla"]}, None,
                                  None, None) == ([], {}, {})

    types["gpubla"]["max_workers"] = 10
    assert _add_min_workers_nodes([], {}, {"gpubla": types["gpubla"]}, None,
                                  None, None) == ([{
                                      "GPU": 1
                                  }] * 10, {
                                      "gpubla": 10
                                  }, {
                                      "gpubla": 10
                                  })
    # yapf: enable

Versions / Dependencies

  • Python: 3.8.12
  • OS: macOS 11.5.2
  • Black: 21.12b0
  • Ray commit: 14ed7cfaaa8f890204619c149d4d50b5857c3cd6

Reproduction script

black python/ray/tests/test_resource_demand_scheduler.py

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 a pull request may close this issue.

1 participant