Skip to content

skip @inferred tests for PkgEval#165

Merged
simeonschaub merged 7 commits intomasterfrom
sds/skip_inferred
Jun 8, 2021
Merged

skip @inferred tests for PkgEval#165
simeonschaub merged 7 commits intomasterfrom
sds/skip_inferred

Conversation

@simeonschaub
Copy link
Member

They can also be manually disabled by setting CHAINRULES_TEST_INFERRED
to false. I have tested that all tests still pass with JULIA_PKGEVAL
set to true, do we need to test for that by spawning a new Julia
process? Once this is merged, I plan to replace occurences of
@inferred in ChainRules with @maybe_inferred as well, therefore I
exported that macro.

They can also be manually disabled by setting `CHAINRULES_TEST_INFERRED`
to `false`. I have tested that all tests still pass with `JULIA_PKGEVAL`
set to `true`, do we need to test for that by spawning a new Julia
process? Once this is merged, I plan to replace occurences of
`@inferred` in ChainRules with `@maybe_inferred` as well, therefore I
exported that macro.

function __init__()
TEST_INFERRED[] = !parse(Bool, get(ENV, "JULIA_PKGEVAL", "false")) &&
parse(Bool, get(ENV, "CHAINRULES_TEST_INFERRED", "true"))
Copy link
Member

Choose a reason for hiding this comment

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

Possible we want:

TEST_INFERRED[] = if haskey(ENV, "CHAINRULES_TEST_INFERRED")
    parse(Bool, "CHAINRULES_TEST_INFERRED")
else
    !parse(Bool, get(ENV, "JULIA_PKGEVAL", "false"))
end

which as truth table
for C being ENV[CHAINRULES_TEST_INFERRED] and
P being JULIA_PKGEVAL
and X marking not defined

C P R
-----
X T F
X F T
F F F
F T F
T F T
T T T
T X T
F X F
X X T

over

TEST_INFERRED[] = !parse(Bool, get(ENV, "JULIA_PKGEVAL", "false")) &&
    parse(Bool, get(ENV, "CHAINRULES_TEST_INFERRED", "true"))

which has

C P R
-----
X T F
X F T
F F F
F T F
T F T
T T F
T X T
F X F
X X T

The difference is the
T T T vs T T F.
I.e. if the ChainRules specific environment variable is present, it would override the JULIA_PKGEVAL.
Which feels right to me.
If someone specifically states they want these tests to run that is stronger than if it happens to have this enviroment varaible set.

Also do we want to handle the variables not being set to parsable values?
If so could be done with try_parse + something, or the a try-catch + give an informative message.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we don't need the two env-vars.
Maybe we just need !parse(Bool, get(ENV, "JULIA_PKGEVAL", "false")) to see the default value.
And then for normal users (and for overwriting) we can document doing ChainRulesTestUtils.TEST_INFERRED[]=false / ChainRulesTestUtils.TEST_INFERRED[]=true

Maybe that is better?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think a separate environment variable might still be useful, since otherwise, you'd have to manually edit the testing code to disable these. I didn't really expect the two env vars to ever really be set at the same time, but just for consistency's sake I agree that your version makes more sense, so I will go with that instead if that's ok.

end

"""
@maybe_inferred f(...)
Copy link
Member

Choose a reason for hiding this comment

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

Can we think of a better name for this?
Might not be able to.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe_test_inferred is perhaps more accurate?

Copy link
Member

Choose a reason for hiding this comment

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

I wish @inferred has been named @test_inferred (and that it returnned a bool rather than erroring)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that it's not the greatest name, but I couldn't really think of a better one. Since it isn't an actual test I don't think it should have test in its name, but I am open to any other suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

We could make it an actual test

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'd prefer to make it consistent with base, so it's just a drop-in replacement for @inferred. We could think about having an @maybe_test_inferred as well, but for now this seems more straightforward to me.

@oxinabox
Copy link
Member

oxinabox commented Jun 4, 2021

do we need to test for that by spawning a new Julia process?

We do not.
But we probably should check that non-inferrable tests do pass if we disable it manually?

Copy link
Member

@oxinabox oxinabox left a comment

Choose a reason for hiding this comment

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

Needs adding to docs.
I trust your judgement wrapping things up here, and addressing the points i raised appropriately.

@simeonschaub
Copy link
Member Author

I plan on merging this tomorrow afternoon if there are no objections.

@simeonschaub simeonschaub merged commit 40a236a into master Jun 8, 2021
@simeonschaub simeonschaub deleted the sds/skip_inferred branch June 8, 2021 14:23
@simeonschaub
Copy link
Member Author

Oh, sorry, I thought I bumped the version as well, but seems like I missed it. Ok if I just do that as a commit straight to master or is the proper way to do this in its own PR?

@mzgubic
Copy link
Member

mzgubic commented Jun 8, 2021

yeah just commit the version bump

simeonschaub added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Jun 8, 2021
ref JuliaDiff/ChainRulesTestUtils.jl#165.

I will bump the version as well once #434 is merged so that PkgEval
picks this up.
simeonschaub added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Jun 8, 2021
ref JuliaDiff/ChainRulesTestUtils.jl#165.

I will bump the version as well once #434 is merged so that PkgEval
picks this up.
@simeonschaub simeonschaub mentioned this pull request Jun 9, 2021
4 tasks
oxinabox added a commit that referenced this pull request Jul 21, 2021
Make rand_tangent on adjoint an transpose return natural
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 this pull request may close these issues.

4 participants