# Not sure if I am using \`Revise\` correctly

**URL:** <https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774>\
**Category:** General Usage\
**Created:** [March 9, 2021, 12:50am UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774 "2021-03-09T00:50:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [March 9, 2021, 12:50am UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/1 "2021-03-09T00:50:57Z")

</div>

I am trying to use Revise for a module `mymodule` defined in the file `model.jl`.

```julia
julia> using Revise
julia> include("model.jl"); using .mymodule

```

if I change the file `model.jl` , the changes are not reflected. I imagine that it’s tracking the “module” `.mymodule` rather than watching for changes in the file. Infact,

```julia
julia> Revise.modulefiles(mymodule)
(nothing, nothing)

```

which, from the docs, suggests

```julia
Return the parentfile in which mod was defined, as well as a list of any other files that were included to define mod. If this operation is unsuccessful, (nothing, nothing) is returned.

```

Is there a way to fix this?

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1615249366132000?thread_ts=1615249366.132000&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

Mods: Please change title to “Using Revise with pmap, parallel workers, and relative module”

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [March 9, 2021, 12:54am UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/2 "2021-03-09T00:54:23Z")

</div>

The solution here is to use `Revise.track`.

```julia
include("model.jl")
using Revise; Revise.track("model.jl")
using .mymodule

```

My usecase actually involved using `Distributed` and multiple workers. For that, the following snippet worked:

```julia
# julia> using Distributed; addprocs(4, exeflags="--project=.")
# julia> @everywhere include("model.jl")
# julia> using Revise; Revise.track("model.jl")
# julia> @everywhere using .mymodule

```

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 9, 2021, 7:04am UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/3 "2021-03-09T07:04:14Z")

</div>

It’s also worth pointing out that since you’ve gone to the effort to create a module, going one step further to make it available as a package means you don’t need do anything more than

```julia
using Revise, MyModel

```

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [March 9, 2021, 3:47pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/4 "2021-03-09T15:47:49Z")

</div>

Yes, but how exactly do I do that? I guess I could develop in `./julia/dev` and then `dev` the package in my environment. The problem is that I am using two systems. My local for testing and plotting and then a cluster system for running the main simulations, so it’s just easier to upload my script.jl file and run include. I guess, if I am uploading files, I could upload to the `dev` folder on the cluster as well.

By the way, @tim.holy could you verify my thought process here?

- By running `using Revise; using .mymodule`, Revise is indeed tracking my module. But since there is no file path to this module, Revise won’t actually know when changes are made (i.e. I’ve made changes to a file, not the module per se).

- By running `Revise.track("model.jl")`, it’s not tracking both the file `model.jl` and module `mymodule`. When I made changes to `model.jl`, it updates the the included code, but since the included code is simply the module, `.mymodule` also gets updated.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 9, 2021, 5:42pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/5 "2021-03-09T17:42:15Z")

</div>

I use PkgTemplates when I first start a new project so the whole directory structure is there and under git version control. I then push my code up to GitHub and use that to deploy to other systems. GitHub gives us, as an academic lab, unlimited free private repositories.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [March 9, 2021, 6:02pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/6 "2021-03-09T18:02:52Z")

</div>

> [@tim.holy](#):
>
> GitHub gives us, as an academic lab, unlimited free private repositories.

GitHub has unlimited private repositories for unpaid users too ([Pricing · Plans for every developer · GitHub](https://github.com/pricing)).

> [@affans](#):
>
> I guess I could develop in `./julia/dev` and then `dev` the package in my environment.

My experience is also that packages win almost in all cases. With packages, you get many benefits almost for free, such as

- setting up tests and documentation
- using your code in other places
- dependency management (via `Project.toml`)

Also, you don’t have to put much in `~/.julia/dev`. Instead, use

```julia
julia> ]

pkg> activate .

(MyPackage)> # Type a backspace here to go back to julia>

julia> using Revise; using MyPackage

```

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [March 9, 2021, 7:34pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/7 "2021-03-09T19:34:00Z")

</div>

Well, isn’t that still slightly more complicated?

I develop a package on my local, in the `./julia/dev` folder. This is great, as locally all I have to do is `using Revise, MyModule` and just keep working. I can even occasionally push to github if the folder is git initialized.

But my workflow is slightly different. The problem for me is that, often I make a change, I test it out locally, but then need to immediately upload to a cluster, and test out my changes at a much larger scale (think calibrating a large agent-based model where I need to run a few hundred realizations to get meaningful results).

So with my current solution, all I have to do is work locally, save the file, and upload to cluster (one command in vscode extension). And because I am tracking the file `model.jl` using Revise, my code is automatically updated (not only on the main process, but also on the worker processes as well). I find this workflow very efficient.

Using it the “package” way, I have to push to github even after the smallest change, then `up` on the cluster, restart Julia, and `using MyModule` again. Revise dosn’t end up being useful for me.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 9, 2021, 7:38pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/8 "2021-03-09T19:38:53Z")

</div>

No, you can have a branch, then have Revise open on both the cluster and your local computer.

Push and pull from the branch only, and Revise will track both just fine.

EDIT: Don’t use `up`, use the git repo directly to manage updates.

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [March 9, 2021, 7:44pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/9 "2021-03-09T19:44:18Z")

</div>

Okay, thanks. I will work on a MWE and update this thread and even submit a documentation PR.

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [March 10, 2021, 8:21am UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/10 "2021-03-10T08:21:39Z")

</div>

It seems to me that “packages” that `Revise` can track don’t have to have the full blown package structure that `Pkg` knows how to work with. I.e. a “package” consisting of a file named “MyModel.jl” (with possibly `include`d files) in a directory in the `LOAD_PATH` and containing a module `MyModel` can be tracked with `Revise` via `using Revise, MyModel`.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 11, 2021, 1:23pm UTC](https://discourse.julialang.org/t/not-sure-if-i-am-using-revise-correctly/56774/11 "2021-03-11T13:23:24Z")

</div>

@affans, there are several viable solutions here, so you should just pick the one that works for you. Your first post didn’t spell out all your constraints, so I and others suggested alternatives to the solution you found, but in the end you know what works for you best.
