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

Documentation for contributing to KomaMRI using VSCode #382

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

beorostica
Copy link
Contributor

@beorostica beorostica commented Apr 23, 2024

@cncastillo cncastillo changed the title Documentation for developing KomaMRI Documentation for contributing to KomaMRI using VSCode Apr 23, 2024
@cncastillo cncastillo added the documentation Improvements to docs., it also triggers doc preview label Apr 23, 2024
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.47%. Comparing base (647ebdf) to head (6606041).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #382   +/-   ##
=======================================
  Coverage   89.47%   89.47%           
=======================================
  Files          43       43           
  Lines        2728     2728           
=======================================
  Hits         2441     2441           
  Misses        287      287           
Flag Coverage Δ
base 86.42% <ø> (ø)
core 86.93% <ø> (ø)
files 93.70% <ø> (ø)
komamri 93.96% <ø> (ø)
plots 89.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@cncastillo cncastillo left a comment

Choose a reason for hiding this comment

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

The text is overly complicated, and the images give little information. The section's name should make sense, "How to ... Advanced Users" ? Please modify as suggested.

docs/src/how-to/4-develop.md Outdated Show resolved Hide resolved
Comment on lines 11 to 102
## Setup your Fork of KomaMRI

Once everything is installed, you need to create a fork of the KomaMRI repo in your Github account. Go to the official KomaMRI repo https://github.com/JuliaHealth/KomaMRI.jl and follow the bellow steps:

![](../assets/dev-fork.png)
![](../assets/dev-fork-create.png)

Now, your fork of KomaMRI should look like this:

![](../assets/dev-fork-github.png)

Now you need to clone your fork of the KomaMRI repo. In julia you can do this by opening a terminal and typing (make sure you change the `<github-username>`):
```julia-repl
(@v1.10) pkg> dev https://github.com/<github-username>/KomaMRI.jl
```

This saves the local git project at the `~/.julia/dev/KomaMRI/` directory. You can open VScode and open this folder, it should look like this:

![](../assets/dev-vscode-git-project.png)

Everything looks good. Let's run KomaMRI, but before you can do so, you need to setup the Julia environment. The information of the environment is ultimately defined by the file `Manifest.toml`, however you don't have that file yet. So you need to create it from the information of the `Project.toml`.

Let's select the environment of our KomaMRI project:

![](../assets/dev-vscode-select-komamri-environment.png)

Now, open a Julia REPL:

![](../assets/dev-open-julia-repl.png)

In the Julia REPL you have to create the `Manifest.toml` file with the `develop` command considering de local folders `KomaMRIBase`, `KomaMRICore`, `KomaMRIFiles` and `KomaMRIPlots`. Additionally you can install all the dependencies listed in the `Manifest.toml` with the `instantiate` command:
```julia-repl
(KomaMRI) pkg> dev ./KomaMRIBase ./KomaMRICore ./KomaMRIFiles ./KomaMRIPlots

(KomaMRI) pkg> instantiate
```

With these steps your environment is setup. You can now run the KomaMRI user interface:
```julia-repl
julia> using KomaMRI

julia> KomaUI()
```
![](../assets/dev-launch-ui.png)

Let's see what is the default phantom in the user interface by clicking in the `Phantom dropdown` and then press the `View Phantom` button:

![](../assets/dev-default-phantom-brain.png)

You can close the KomaMRI user interface.


## Make changes to remote repos

So far so good. However you want to make some changes to your Github Fork and even you want to contribute to the KomaMRI project. But first, let's make some local changes in the local git repo. In the following example we will change the default phantom displayed in the user interface.

First create a branch with a descriptive name, in this case `patch-ui-default-phantom`:

![](../assets/dev-branch.png)
![](../assets/dev-branch-name.png)

In this new branch, we are going to edit the `setup_phantom` function located in the file `src/ui/ExportUIFunctions.jl`. We simply replace the line where a brain phantom is defined by the function `pelvis_brain2D`:

![](../assets/dev-branch-edit.png)

Then, you need to compile the function `setup_phantom`, simply put the cursor in a place inside the function `setup_phantom` and then press `Alt + Enter`:

![](../assets/dev-branch-compile.png)

Now, let's see what is the new default phantom in the user interface by clicking in the `Phantom dropdown` and then press the `View Phantom` button:

```julia-repl
julia> KomaUI()
```

![](../assets/dev-default-phantom-pelvis.png)

Everything looks good, let's stage the changes:

![](../assets/dev-stage-changes.png)

And commit the changes:

![](../assets/dev-commit-changes.png)

Let's upload these changes in your github fork or to the official KomaMRI repo by selecting the `origin` or the `upstream` option:

![](../assets/dev-publish.png)

![](../assets/dev-pullreq.png)

![](../assets/dev-pullreq-name.png)
Copy link
Member

Choose a reason for hiding this comment

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

Installing KomaMRI as a developer

Install dev version of Koma:
Now we will use the REPL to install Koma as a developer:

pkg> dev KomaMRI

This command will clone KomaMRI.jl's repository (dev version) to ~/.julia/dev/KomaMRI.jl/.

Open Koma dev in VSCode:
Now, open this folder in VScode using File/Open Folder... in the menu bar. The Julia extension should automatically detect the KomaMRI environment. To check this, look at the status bar (bottom) and you should see Julia env: KomaMRI.jl. If this is not the case, click the option in the menu bar and select KomaMRI.jl.

KomaMRI monorepo setup:
As KomaMRI.jl contains multiple packages in one GitHub repository, you need to specify that you want to use your local copies (instead of the ones available on the Julia registries) with:

(KomaMRI) pkg> dev ./KomaMRIBase ./KomaMRICore ./KomaMRIFiles ./KomaMRIPlots

Finally, use the instantiate command to install all the required packages (specified in the Project.toml):

(KomaMRI) pkg> instantiate

This will also include all the specific package versions into the Manifest.toml. The Manifest.toml should not be uploaded to the repo when making a commit or pull request. Thus, it is present in the .gitignore.

Comment on lines +103 to +104


Copy link
Member

Choose a reason for hiding this comment

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

Forking Koma

If you try to commit or generate a pull request at this point, you will get an Access denied error. This is because you need to create a fork before you can contribute to this repository directly (unless you are included as a collaborator!). To create a fork of KomaMRI.jl, go to KomaMRI.jl's GitHub and click the "Fork" button and follow the instructions:

image

To use you fork in VSCode click "master" in the status bar:

image

and select your remote branch username/KomaMRI.jl.

Comment on lines 10 to 102

## Setup your Fork of KomaMRI

Once everything is installed, you need to create a fork of the KomaMRI repo in your Github account. Go to the official KomaMRI repo https://github.com/JuliaHealth/KomaMRI.jl and follow the bellow steps:

![](../assets/dev-fork.png)
![](../assets/dev-fork-create.png)

Now, your fork of KomaMRI should look like this:

![](../assets/dev-fork-github.png)

Now you need to clone your fork of the KomaMRI repo. In julia you can do this by opening a terminal and typing (make sure you change the `<github-username>`):
```julia-repl
(@v1.10) pkg> dev https://github.com/<github-username>/KomaMRI.jl
```

This saves the local git project at the `~/.julia/dev/KomaMRI/` directory. You can open VScode and open this folder, it should look like this:

![](../assets/dev-vscode-git-project.png)

Everything looks good. Let's run KomaMRI, but before you can do so, you need to setup the Julia environment. The information of the environment is ultimately defined by the file `Manifest.toml`, however you don't have that file yet. So you need to create it from the information of the `Project.toml`.

Let's select the environment of our KomaMRI project:

![](../assets/dev-vscode-select-komamri-environment.png)

Now, open a Julia REPL:

![](../assets/dev-open-julia-repl.png)

In the Julia REPL you have to create the `Manifest.toml` file with the `develop` command considering de local folders `KomaMRIBase`, `KomaMRICore`, `KomaMRIFiles` and `KomaMRIPlots`. Additionally you can install all the dependencies listed in the `Manifest.toml` with the `instantiate` command:
```julia-repl
(KomaMRI) pkg> dev ./KomaMRIBase ./KomaMRICore ./KomaMRIFiles ./KomaMRIPlots

(KomaMRI) pkg> instantiate
```

With these steps your environment is setup. You can now run the KomaMRI user interface:
```julia-repl
julia> using KomaMRI

julia> KomaUI()
```
![](../assets/dev-launch-ui.png)

Let's see what is the default phantom in the user interface by clicking in the `Phantom dropdown` and then press the `View Phantom` button:

![](../assets/dev-default-phantom-brain.png)

You can close the KomaMRI user interface.


## Make changes to remote repos

So far so good. However you want to make some changes to your Github Fork and even you want to contribute to the KomaMRI project. But first, let's make some local changes in the local git repo. In the following example we will change the default phantom displayed in the user interface.

First create a branch with a descriptive name, in this case `patch-ui-default-phantom`:

![](../assets/dev-branch.png)
![](../assets/dev-branch-name.png)

In this new branch, we are going to edit the `setup_phantom` function located in the file `src/ui/ExportUIFunctions.jl`. We simply replace the line where a brain phantom is defined by the function `pelvis_brain2D`:

![](../assets/dev-branch-edit.png)

Then, you need to compile the function `setup_phantom`, simply put the cursor in a place inside the function `setup_phantom` and then press `Alt + Enter`:

![](../assets/dev-branch-compile.png)

Now, let's see what is the new default phantom in the user interface by clicking in the `Phantom dropdown` and then press the `View Phantom` button:

```julia-repl
julia> KomaUI()
```

![](../assets/dev-default-phantom-pelvis.png)

Everything looks good, let's stage the changes:

![](../assets/dev-stage-changes.png)

And commit the changes:

![](../assets/dev-commit-changes.png)

Let's upload these changes in your github fork or to the official KomaMRI repo by selecting the `origin` or the `upstream` option:

![](../assets/dev-publish.png)

![](../assets/dev-pullreq.png)

![](../assets/dev-pullreq-name.png)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## Setup your Fork of KomaMRI
Once everything is installed, you need to create a fork of the KomaMRI repo in your Github account. Go to the official KomaMRI repo https://github.com/JuliaHealth/KomaMRI.jl and follow the bellow steps:
![](../assets/dev-fork.png)
![](../assets/dev-fork-create.png)
Now, your fork of KomaMRI should look like this:
![](../assets/dev-fork-github.png)
Now you need to clone your fork of the KomaMRI repo. In julia you can do this by opening a terminal and typing (make sure you change the `<github-username>`):
```julia-repl
(@v1.10) pkg> dev https://github.com/<github-username>/KomaMRI.jl
```
This saves the local git project at the `~/.julia/dev/KomaMRI/` directory. You can open VScode and open this folder, it should look like this:
![](../assets/dev-vscode-git-project.png)
Everything looks good. Let's run KomaMRI, but before you can do so, you need to setup the Julia environment. The information of the environment is ultimately defined by the file `Manifest.toml`, however you don't have that file yet. So you need to create it from the information of the `Project.toml`.
Let's select the environment of our KomaMRI project:
![](../assets/dev-vscode-select-komamri-environment.png)
Now, open a Julia REPL:
![](../assets/dev-open-julia-repl.png)
In the Julia REPL you have to create the `Manifest.toml` file with the `develop` command considering de local folders `KomaMRIBase`, `KomaMRICore`, `KomaMRIFiles` and `KomaMRIPlots`. Additionally you can install all the dependencies listed in the `Manifest.toml` with the `instantiate` command:
```julia-repl
(KomaMRI) pkg> dev ./KomaMRIBase ./KomaMRICore ./KomaMRIFiles ./KomaMRIPlots
(KomaMRI) pkg> instantiate
```
With these steps your environment is setup. You can now run the KomaMRI user interface:
```julia-repl
julia> using KomaMRI
julia> KomaUI()
```
![](../assets/dev-launch-ui.png)
Let's see what is the default phantom in the user interface by clicking in the `Phantom dropdown` and then press the `View Phantom` button:
![](../assets/dev-default-phantom-brain.png)
You can close the KomaMRI user interface.
## Make changes to remote repos
So far so good. However you want to make some changes to your Github Fork and even you want to contribute to the KomaMRI project. But first, let's make some local changes in the local git repo. In the following example we will change the default phantom displayed in the user interface.
First create a branch with a descriptive name, in this case `patch-ui-default-phantom`:
![](../assets/dev-branch.png)
![](../assets/dev-branch-name.png)
In this new branch, we are going to edit the `setup_phantom` function located in the file `src/ui/ExportUIFunctions.jl`. We simply replace the line where a brain phantom is defined by the function `pelvis_brain2D`:
![](../assets/dev-branch-edit.png)
Then, you need to compile the function `setup_phantom`, simply put the cursor in a place inside the function `setup_phantom` and then press `Alt + Enter`:
![](../assets/dev-branch-compile.png)
Now, let's see what is the new default phantom in the user interface by clicking in the `Phantom dropdown` and then press the `View Phantom` button:
```julia-repl
julia> KomaUI()
```
![](../assets/dev-default-phantom-pelvis.png)
Everything looks good, let's stage the changes:
![](../assets/dev-stage-changes.png)
And commit the changes:
![](../assets/dev-commit-changes.png)
Let's upload these changes in your github fork or to the official KomaMRI repo by selecting the `origin` or the `upstream` option:
![](../assets/dev-publish.png)
![](../assets/dev-pullreq.png)
![](../assets/dev-pullreq-name.png)

Comment on lines 105 to 136
## About Julia Environments and Subdirectories

So far, the `KomaMRI` package have 4 subdirectories `KomaMRIBase`, `KomaMRICore`, `KomaMRIPlots` and `KomaMRIFiles`. These subdirectories are proper julia packages by themselves, so they have their own `Project.toml` which need to resolve an environment defined ultimately by a `Manifest.toml`.

This is how these packages are related:
* `KomaMRIBase` doesn't depend on any of these other subdirectories.
* `KomaMRICore` depends directly on `KomaMRIBase`
* `KomaMRIPlots` depends directly on `KomaMRIBase`
* `KomaMRIFiles` depends directly on `KomaMRIBase`
* `KomaMRI` depends directly on `KomaMRICore`, `KomaMRIPlots` and `KomaMRIFiles`

If you want to edit only the direct contents of one of these packages, you simply need to activate the julia package and then instantiate to generate the `Manifest.toml` and install dependencies. However, if you want to make changes that involve the packages and it's direct dependencies you need to create an environment that indicates so.

For instance, to edit `KomaMRICore` and its direct dependency `KomaMRIBase` you need to create the `Manifest.toml` like so:
```julia-repl
user@machine ~/.julia/dev/KomaMRI
$ julia

(@v1.10) pkg> activate KomaMRICore

(KomaMRICore) pkg> dev ./KomaMRIBase
```

And for creating the `Manifest.toml` file of `KomaMRI`which considers all the subdirectories you have to do:
```julia-repl
user@machine ~/.julia/dev/KomaMRI
$ julia

(@v1.10) pkg> activate .

(KomaMRI) pkg> dev ./KomaMRIBase ./KomaMRICore ./KomaMRIFiles ./KomaMRIPlots
```
Copy link
Member

@cncastillo cncastillo Apr 23, 2024

Choose a reason for hiding this comment

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

Commiting your first pull request

So far, so good. Let's make some changes.

Create a branch:
First, create a branch with a descriptive name, in this case my-new-cool-feature:

image

Make some changes to the code:
CHANGE TO SIMPLER EXAMPLE. Modify README, or something.

Commit changes:
TODO. We encourage to

Publish a pull request:
TODO

Review process:
In Koma we require all pull requests to pass our automated tests ... TODO ... do not be afraid if you get an X in nightly because ...


## About Julia Environments and Subdirectories

So far, the `KomaMRI` package have 4 subdirectories `KomaMRIBase`, `KomaMRICore`, `KomaMRIPlots` and `KomaMRIFiles`. These subdirectories are proper julia packages by themselves, so they have their own `Project.toml` which need to resolve an environment defined ultimately by a `Manifest.toml`.
Copy link
Contributor

Choose a reason for hiding this comment

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

So far, the KomaMRI package has 4 subdirectories: KomaMRIBase, KomaMRICore, KomaMRIPlots and KomaMRIFiles. These subdirectories are julia packages by themselves, so they have their own Project.toml which is needed to resolve the environment ultimately defined by Manifest.toml. The directories are not separate git submodules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements to docs., it also triggers doc preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants