nexuse_repo_instruction.md 9.99 KB
Newer Older
1
### **Repository instructions**
2

3
4
5
6
For a full instruction to work with git repository, please see [here](https://git-scm.com/doc).  

This document is only used to demonstrate git operations for certain nexus-e-related questions and use cases:
- [How do I get the repository?](#how-do-i-get-the-repository) 
7
  - Short answer: you "git clone" it from <https://gitlab.ethz.ch/nexus-e/nexus-e-framework.git> to a local folder.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
- [What is the structure of the repository?](#what-is-the-structure-of-the-repository)
  - Short answer: it is an overarching reposity called "nexus-e" containing sub-repositories ("[submodules](https://www.git-scm.com/book/en/v2/Git-Tools-Submodules)" is the official term in git).
- [I want to make changes in my own module. What should I do first?](#i-want-to-make-changes-in-my-own-module-what-should-i-do-first)
  - Short answer: be aware of where you are in other modules. If needed, pull changes from other submodules.
- [I have made some changes in my own module and tested them in a small scale. How do I test them with the full Nexus-e platform?](#i-have-made-some-changes-in-my-own-module-and-tested-them-in-a-small-scale-how-do-i-test-them-with-the-full-nexus-e-platform)
  - Short answer: depending on the scale of your change - if small, you might want to copy the changed file(s) to Euler; if large, you might want to push the changes first then pull it on Euler.
- [I have fully tested my changes in my own module. What should I do now?](#i-have-fully-tested-my-changes-in-my-own-module-what-should-i-do-now)
  - Short answer: push what you have tested (maybe not only your own module) into the overarching repo.

We recommend to use a git GUI (e.g. GitKraken, Git Extensions, SourceTree, and [many more](https://git-scm.com/downloads/guis)) to work with git locally. However, Euler doesn't have a GUI, therefore you have to use command line there. In this documentation, we demonstrate with the GUI "GitKraken". You can get a [pro account for free as a researcher](https://education.github.com/toolbox?utm_source=github+gitkraken). The screenshots are taken from MacOS. There should be equivalent operations on other operating systems. 

Why GitKraken:
- It is stable in all operating systems (Linux, Mac, Windows)
- It provides a good overview for the status of submodules, which is the key structure of our Nexus-e repo.
22
- It has an embeded & very handy merging conflict resolution tool.
23
24
25
26
27
28
29
30
31
32
- It is mature and well-documented.

#### How do I get the repository?
(1) Clone the overarching repo
![](images/gitkraken-clone.png)
(2) Put in your credentials for the repo (normally your ETH account)
![](images/gitkraken-credentials.png)
(3) Initialize the submodules (select "Yes")
![](images/gitkraken-initialize-submodules.png)

33
Afterwards, you will see submodules getting initialized one by one (In the screenshot below there are 7 submodules. Since January 2021, it is reduced to 5 submodules.):
34
35
36
37
38
39
40
![](images/gitkraken-finish-clone.png)

#### What is the structure of the repository?
To help with understanding, we show both interfactes in GitKraken (left) and in the repository (right).
![](images/gitkraken-repo-structure.png)

#### I want to make changes in my own module. What should I do first?
41
For example, you want to make changes in the "Shared" module. Note: Since January 2021, "Shared" is not a submodule anymore but a folder directly under the Nexus-e repository, but the procedures demonstrated here can be applied to any submodules.  
42
43
44
45
46
47
48
49
50
(1) Open the submodule "Shared".
![](images/gitkraken-open-shared.png)
(2) After entering the submodule "Shared", you might see such a structure.
![](images/gitkraken-enter-shared.png)
(3) Fast-forward your branch to "master" to make sure your local codes are up-to-date.
![](images/gitkraken-fast-forward.png)
(4) Now your own branch is at the same level as "master".
![](images/gitkraken-after-fast-forward.png)
(5) Sometimes you might need to update other modules as well.  
51
52
E.g., if your change in the "Shared" module depends on the newest changes in the "CentIv" module which is in the "target_branch" branch (doesn't have to be the "master" branch), you will need to go through a similar procedure:
  - Enter "CentIv" submodule.  
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  - Fast-forward your own branch to the "target_branch".

(6) In the end, you could enter all submodules one by one to make sure that you are at the right place in all of them.


#### I have made some changes in my own module and tested them in a small scale. How do I test them with the full Nexus-e platform?
To test the full platform, you will need to move your codes with your changes to Euler and [run Nexus-e on Euler](setup.html#id3).  

There are two ways to get codes to Euler: (1) copy from your local and (2) use git. Here we list the pros, cons, and use cases of both ways. You could decide which way to use.

- Comparison
  - Copy from local
    - Pro: (1) This can be done with a GUI tool. (2) You don't need to push to the repository first.
    - Con: (1) Copying the whole Nexus-e folder takes time (a few minutes). (2) If you only copy selected files where you have made changes, you might by accident forget some.
    - When to use: (1) when you need to test small changes that you don't want to push to the repository yet, and (2) when you can't push to git, e.g., when you made changes in a repo where you don't have permission to push.

  - Git
    - Pro: (1) Using git gaurantees that what you run on Euler is exactly the same as in the repository. (2) It is fast because only updated files will be reloaded by git and some files (e.g. results) are ignored by git.
    - Con: (1) You need to run git commands in a terminal (no GUI). (2) You need to push your codes to the repository first and then pull it to Euler
    - When to use: (1) When you want to test what is already in the repository, and (2) when you have made lots of changes to the codes and you might forget some files when you copy them to Euler manually.


- Copy from local
  - Use a [graphical tool](https://scicomp.ethz.ch/wiki/Getting_started_with_clusters#Graphical_tools) to transfer files between Euler and your local computer. 
  - Copy your whole Nexus-e folder (you don't have to copy the "Results" folder) to Euler. 
  - Alternatively, you could also only copy individual files where you made changes, but you risk forgetting some files or forgetting to update some modules on Euler.

- Use git  
In this section, we assume that you already have Nexus-e codes on Euler, so you only need to update the codes where you have made changes. If this is not the case, follow the section [Euler setup](setup.html#euler-setup).  
  - First, make sure to have a clean start - all submodules should be on the most updated "master" branch.

    (1) On Euler, go to the folder where you put the Nexus-e codes. e.g.,  
    ```cd nexus-e```  
    (2) Update all submodules
Xuqian Yan's avatar
Xuqian Yan committed
87
88
      - Delete your local changes  
      ```git submodule foreach "git reset --hard"```
89
90
91
92
93
94
95
96
97
98
99
100
101
102
      - Switch to the master branchs in all submodules  
      ```git submodule foreach "git checkout master"``` 
      - Pull the latest updates in the master branchs  
      ```git submodule foreach "git pull"```  

  - Then, go to the individual submodules where you want to pull changes that are not in the "master" branch. For example, you want to test your changes in the "Shared" submodule which is pushed to a branch named as "postprocess".

    (1) Go to the folder where you want to pull the changes, e.g.,  
    ```cd Shared```  
    (2) Check which branch you are at right now with  
    ```git branch```  
    E.g., in the screenshot below, it is at the "xuqian" branch (seen from the "\*" sign) and there is **no "postprocess" branch yet**.   
    (Note: This is the most complicated case. For example, if you already have the "postprocess" branch and you are already at the "postprocess" branch, you could skip the following steps and only run `git pull`. See more information on switching branch with [git checkout](https://git-scm.com/docs/git-checkout) and updating the current branch with [git pull](https://git-scm.com/docs/git-pull).)  
    ![](images/euler-git-branch.png)  
103
104
105
    (3) Fetch the origin  
    ```git fetch origin```  
    (4) Pull changes in the "postprocess" remote branch with  
106
    ```git pull origin postprocess```    
107
    You will see the following message asking for your credentials for the "Shared" repo.
108
    ![](images/euler-git-pull-origin.png)  
109
    (5) Create and check out local branch "postprocess" with  
110
111
    ```git checkout -b postprocess origin/postprocess```  
    ![](images/euler-git-checkout.png)  
112
    (6) Check your branch again with `git branch` to make sure that you are at the "postprocess" branch.
113
114
115
116
117
118
    ![](images/euler-git-branch-new.png)

  - Sometimes you need to do the branch switching (as instructed in the step above) for other submodules as well. From [here](#i-want-to-make-changes-in-my-own-module-what-should-i-do-first), you should already know which branch you are at in each submodule. 

#### I have fully tested my changes in my own module. What should I do now?
For example, you have made changes on the branch "florian" in the submodule "Gemel". The changes have been tested together with the updated module "Run_Nexuse". Now you are confident about the codes and you want other researchers also use your updates.  
119
Note: Since January 2021, "Run_Nexuse" is not a submodule anymore but a folder directly under the Nexus-e repository, but the procedures demonstrated here can be applied to any submodules.  
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
(1) Enter the "Gemel" submodule.
![](images/gitkraken-enter-gemel.png)  
(2) Checkout origin/master
![](images/gitkraken-checkout-master.png)  
(3) Merge "florian" into "master"
![](images/gitkraken-merge-master.png)  
(4) Push the "master" branch  
![](images/gitkraken-push-master.png)  
(5) Enter the "Run_Nexuse" submodule and make sure you are at the right commit  
![](images/gitkraken-double-check.png)  
(6) Go back to the overarching repo, stage the "Gemel" and "Run_Nexuse" modules  
![](images/gitkraken-stage-modules.png)  
(7) Commit your changes  
![](images/gitkraken-commit.png)  
(8) Push your changes  
![](images/gitkraken-push-overarching-repo.png)  




140