-
Notifications
You must be signed in to change notification settings - Fork 2
/
stuff in notebook.py
142 lines (121 loc) · 3.83 KB
/
stuff in notebook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
!pip3 install kfp
import kfp
import kubernetes
container_manifest = {
"apiVersion": "sparkoperator.k8s.io/v1beta2",
"kind": "SparkApplication",
"metadata": {
"name": "spark-app",
"namespace": "kubeflow"
},
"spec": {
"type": "Scala",
"mode": "cluster",
"image": "docker.io/rawkintrevo/covid-basis-vectors:0.2.0",
"imagePullPolicy": "Always",
"hadoopConf": {
"fs.gs.project.id": "kubeflow-hacky-hacky",
"fs.gs.system.bucket": "covid-dicoms",
"fs.gs.impl" : "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem",
"google.cloud.auth.service.account.enable": "true",
"google.cloud.auth.service.account.json.keyfile": "/mnt/secrets/user-gcp-sa.json",
},
"mainClass": "org.rawkintrevo.covid.App",
"mainApplicationFile": "local:///covid-0.1-jar-with-dependencies.jar", # See the Dockerfile
"arguments": ["245", "15", "1"],
"sparkVersion": "2.4.5",
"restartPolicy": {
"type": "Never"
},
"driver": {
"cores": 1,
"secrets": [
{"name": "user-gcp-sa",
"path": "/mnt/secrets",
"secretType": "GCPServiceAccount"
}
],
"coreLimit": "1200m",
"memory": "512m",
"labels": {
"version": "2.4.5",
},
"serviceAccount": "spark-operatoroperator-sa", # also try spark-operatoroperator-sa
},
"executor": {
"cores": 1,
"secrets": [
{"name": "user-gcp-sa",
"path": "/mnt/secrets",
"secretType": "GCPServiceAccount"
}
],
"instances": 4,
"memory": "4084m"
},
"labels": {
"version": "2.4.5"
},
}
}
# volumes stripped out of this
# volumes stripped out of this
from kfp.gcp import use_gcp_secret
@kfp.dsl.pipeline(
name="Covid DICOM Pipe v2",
description="Create Basis Vectors for Lung Images"
)
def covid_dicom_pipeline():
vop = kfp.dsl.VolumeOp(
name="requisition-PVC",
resource_name="datapvc",
size="20Gi", #10 Gi blows up...
modes=kfp.dsl.VOLUME_MODE_RWO
)
step1 = kfp.dsl.ContainerOp(
name="download-dicom",
image="rawkintrevo/download-dicom:0.0.0.4",
command=["/run.sh"],
pvolumes={"/data": vop.volume}
)
step2 = kfp.dsl.ContainerOp(
name="convert-dicoms-to-vectors",
image="rawkintrevo/covid-prep-dicom:0.9.5",
arguments=[
'--bucket_name', "covid-dicoms",
],
command=["python", "/program.py"],
pvolumes={"/mnt/data": step1.pvolume}
).apply(kfp.gcp.use_gcp_secret(secret_name='user-gcp-sa'))
rop = kfp.dsl.ResourceOp(
name="calculate-basis-vectors",
k8s_resource=container_manifest,
action="create",
success_condition="status.applicationState.state == COMPLETED"
).after(step2)
kfp.compiler.Compiler().compile(covid_dicom_pipeline,"dicom-pipeline-2.zip")
client = kfp.Client()
my_experiment = client.create_experiment(name='my-experiments')
my_run = client.run_pipeline(my_experiment.id, 'my-run1', 'dicom-pipeline-2.zip')
import vtkplotter
from vtkplotter import settings, Plotter
vp = Plotter()
import k3d
vertices = [
-10, 0, -1,
10, 0, -1,
10, 0, 1,
-10, 0, 1,
]
indices = [
0, 1, 3,
1, 2, 3
]
plot = k3d.plot()
plot += k3d.mesh(vertices, indices)
plot.display()
vp = Plotter(screensize=(500,500))
g = vtkplotter.load(vtkplotter.datadir+'timecourse1d/')
from vtkplotter import load
volume = load("/home/rawkintrevo/gits/sidegrifts/basis-vectors-for-covid-kf/data/case001/axial/") #returns a vtkVolume object
show(volume, bg='white')