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

Update warnings and announcements #176

Closed
ChrisRackauckas opened this issue Mar 5, 2018 · 15 comments
Closed

Update warnings and announcements #176

ChrisRackauckas opened this issue Mar 5, 2018 · 15 comments

Comments

@ChrisRackauckas
Copy link
Member

DiffEq has been using a hack by @Datseris to display an announcement in the DiffEq repos.

https://github.com/JuliaDiffEq/DiffEqBase.jl/blob/master/deps/build.jl

While it works, it's quite hacked on so there's issues like SciML/DiffEqBase.jl#94 , but I am wondering if there could be a better way to do announcements than "follow the entire repo" that are built into Pkg3. I for one would love to know about all releases of dependencies for example.

@tpapp
Copy link
Contributor

tpapp commented Mar 6, 2018

Or, more generally, some mechanism for packages to query and save mutable metadata (ie a state) somewhere. Mock code:

using TerminalMenus
if !Pkg3.getmeta("DiffEqBase", "DISABLED_UPDATE_WARNING")
    print("warning")
    if request("do you want to disable this warning in the future?",
               RadioMenu(["disable", "keep"])) == 1
        Pkg3.setmeta("DiffEqBase", "DISABLED_UPDATE_WARNING", true)
    end
end

Pkg3 itself uses environment variables for something similar. These are fine, but can easily proliferate if a lot of packages need something like this.

@KristofferC
Copy link
Sponsor Member

Do you want this metatada to be stored even if the package is deleted? Otherwise, you can just touch a file and look for the presence of it https://github.com/JuliaCI/PkgBenchmark.jl/blob/master/deps/build.jl.

@Datseris
Copy link
Contributor

Datseris commented Mar 6, 2018

Oh wow. That seems like a much better approach!

@KristofferC
Copy link
Sponsor Member

(remember to add the file to .gitignore)

@tpapp
Copy link
Contributor

tpapp commented Mar 7, 2018

It would be great if the solution above could end up as a suggestion in the documentation when that is written, so maybe this issue could be kept open as a reminder.

@KristofferC
Copy link
Sponsor Member

Since we currently redirect the build log to an output file the workaround described above is no longer effective.

@Datseris
Copy link
Contributor

Datseris commented Jul 3, 2018

Since we currently redirect the build log to an output file the workaround described above is no longer effective.

Oh no, seemed like an awesome idea. Do you have any alternative suggestions?

@KristofferC
Copy link
Sponsor Member

You could do almost the same thing but instead when loading the package for the first time.

@tpapp tpapp mentioned this issue Jul 3, 2018
@KristofferC
Copy link
Sponsor Member

I think this can be done by touching a file in the repo and look for the existence of that file and else print the message. This would also show it when you use it instead of when things are building and you are unlikely to pay attention.

@Datseris
Copy link
Contributor

Thanks, seems like a plan! I will soon test it and report here how it went.

@Datseris
Copy link
Contributor

@KristofferC I did this, and it worked like a charm. The update is displayed only once. For reference, this is what I have inside my main MyModule.jl file:

if !isfile(joinpath(@__DIR__, "update_v2.0.0"))
    printstyled(stdout,
    """
    Update text here.
    """; color = Base.info_color())
    touch("update_v2.0.0")
end

However, there is something I don't understand. Where is this file being created? To my understanding it should be at the directory where the package is installed, no? Yet when I go to this directory, I can't seem to find the file:

julia> pwd()
"C:\\Users\\datseris\\.julia\\dev\\DynamicalBilliards"

julia> readdir()
14-element Array{String,1}:
 ".git"
 ".gitignore"
 ".travis.yml"
 "appveyor.yml"
 "benchmark"
 "CHANGELOG.md"
 "docs"
 "ISSUE_TEMPLATE.md"
 "LICENSE.md"
 "paper"
 "README.md"
 "REQUIRE"
 "src"
 "test"

I wanted to delete it to re-test the update message, but I can't find it :D

@Datseris
Copy link
Contributor

Hm, turns it I am not sure whether it worked. I did some changes to my file, but I did not change the file's name.

When DynamicalBilliards was re-compiled, the update message was displayed again.

@fredrikekre
Copy link
Member

Since you used @__DIR__ from MyModule.jl the file will end up in src, no?

@Datseris
Copy link
Contributor

Datseris commented Jul 22, 2018

You are correct. It should be in the src. It isn't though. I think for some reason this file may go where the precompiled caches are?... but it is also not in \.julia\compiled\v0.7\DynamicalBilliards damn!

So the update message just got displayed again after re-compilation. The file though is not in the main folder, not in the src folder, or in the compile folder...

Could it be that touch does not create a file?

edit: touch does create a file. I did cd(); touch("example") and created one in my user directory. Now I am really confused :D Does @__DIR__ not return anymore the directory the file is present in?

@Datseris
Copy link
Contributor

damn I am such a huge moron... look at the code I pasted. I do touch(...) but when searching for the file I Do isfile(joinpath(@__DIR__, "update_v2.0.0")) The correct thing is to also do touch(joinpath(@__DIR__, "update_v2.0.0")) !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants