Skip to content

Commit c2aade3

Browse files
authored
Merge pull request #68 from PytorchConnectomics/refactor
file handling
2 parents d254cd1 + 23a9e23 commit c2aade3

File tree

18 files changed

+3568
-4429
lines changed

18 files changed

+3568
-4429
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.png
66
node_modules/
77
pytc/
8+
pytorch_connectomics/
89
logs/
910
data/
1011
outputs/

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "pytorch_connectomics"]
2-
path = pytorch_connectomics
3-
url = https://github.com/zudi-lin/pytorch_connectomics.git

Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#centOS
22
FROM nvidia/cuda:11.1.1-devel-ubi8
33

4-
# Enable AppStream and install Python 3.9
4+
# Enable AppStream and install Python 3.9 and git
55
RUN yum -y module enable python39 && \
66
yum install -y python39-3.9.2 && \
77
yum install -y python39-devel-3.9.2 && \
8+
yum install -y git && \
89
yum clean all && \
910
(python3.9 --version || echo "Python installation failed" && exit 1)
1011

@@ -21,7 +22,11 @@ WORKDIR /app
2122
# Install dependencies
2223
RUN pip3 install --no-cache-dir torch==1.9.0 torchvision==0.10.0 cuda-python==11.1.1
2324

24-
COPY ./pytorch_connectomics /app/pytorch_connectomics
25+
# Download pytorch_connectomics at specific commit (version 1.0)
26+
RUN git clone https://github.com/zudi-lin/pytorch_connectomics.git /app/pytorch_connectomics && \
27+
cd /app/pytorch_connectomics && \
28+
git checkout 20ccfde
29+
2530
COPY ./samples_pytc /app/samples_pytc
2631
COPY ./server_pytc /app/server_pytc
2732
COPY ./server_api /app/server_api
@@ -35,9 +40,10 @@ WORKDIR /app/server_api
3540
RUN pip3 install --no-cache-dir -r requirements.txt
3641

3742
WORKDIR /app
38-
# Copies the startup script, and runs it at CMD
43+
# Copies the startup scripts, and runs it at CMD
3944
COPY ./start.sh /app/
40-
RUN chmod +x start.sh
45+
COPY ./setup_pytorch_connectomics.sh /app/
46+
RUN chmod +x start.sh setup_pytorch_connectomics.sh
4147

4248
# Expose ports
4349
EXPOSE 4242 4243 4244 6006

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,17 @@ pip install -r requirements.txt
6262

6363
In root folder,
6464
```bash
65+
# The setup script will automatically download pytorch_connectomics at commit 20ccfde (version 1.0)
66+
./setup_pytorch_connectomics.sh
67+
cd pytorch_connectomics
68+
pip install --editable .
69+
```
70+
71+
Alternatively, you can run this manually:
72+
```bash
6573
git clone https://github.com/zudi-lin/pytorch_connectomics.git
6674
cd pytorch_connectomics
75+
git checkout 20ccfde
6776
pip install --editable .
6877
```
6978

client/package-lock.json

Lines changed: 2744 additions & 4207 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"antd": "^5.18.1",
1212
"axios": "^1.7.2",
1313
"buffer": "^6.0.3",
14-
"electron": "^31.2.1",
14+
"electron": "^38.3.0",
1515
"js-yaml": "^4.1.0",
1616
"localforage": "^1.10.0",
1717
"nth-check": "^2.1.1",
@@ -20,7 +20,7 @@
2020
"react": "^18.3.1",
2121
"react-dom": "^18.3.1",
2222
"react-router-dom": "^6.23.1",
23-
"react-scripts": "5.0.1",
23+
"react-scripts": "^5.0.1",
2424
"utif": "^3.1.0",
2525
"web-vitals": "^4.1.1"
2626
},
@@ -58,6 +58,7 @@
5858
"overrides": {
5959
"nth-check": "$nth-check",
6060
"resolve-url-loader": "^5.0.0",
61-
"svgo": "^3.3.2"
61+
"svgo": "^3.3.2",
62+
"webpack-dev-server": "^5.2.1"
6263
}
6364
}

client/src/App.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
1+
import { useContext, useEffect, useState } from 'react'
12
import './App.css'
23
import Views from './views/Views'
3-
import { ContextWrapper } from './contexts/GlobalContext'
4+
import { AppContext, ContextWrapper } from './contexts/GlobalContext'
45
import { YamlContextWrapper } from './contexts/YamlContext'
56

7+
function CacheBootstrapper ({ children }) {
8+
const { resetFileState } = useContext(AppContext)
9+
const [isCacheCleared, setIsCacheCleared] = useState(false)
10+
11+
useEffect(() => {
12+
let isMounted = true
13+
const clearCache = async () => {
14+
await resetFileState()
15+
if (isMounted) {
16+
setIsCacheCleared(true)
17+
}
18+
}
19+
20+
clearCache()
21+
return () => {
22+
isMounted = false
23+
}
24+
}, [resetFileState])
25+
26+
if (!isCacheCleared) {
27+
return null
28+
}
29+
30+
return children
31+
}
32+
633
function App () {
734
return (
835
<ContextWrapper>
936
<YamlContextWrapper>
10-
<div className='App'>
11-
<Views />
12-
</div>
37+
<CacheBootstrapper>
38+
<div className='App'>
39+
<Views />
40+
</div>
41+
</CacheBootstrapper>
1342
</YamlContextWrapper>
1443
</ContextWrapper>
1544
)

0 commit comments

Comments
 (0)