1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#include "parser_toml.h" |
8 |
|
|
|
9 |
|
|
#include "parseRenderFromToml.h" |
10 |
|
|
|
11 |
|
|
///Parse the JobNotification from toml config |
12 |
|
|
/** @param[out] jobNotification : internal representation of the RenderProject |
13 |
|
|
* @param dico : parsed DicoValue |
14 |
|
|
*/ |
15 |
|
11 |
void parseComputingCenter(ComputingCenter & computingCenter, const DicoValue & dico){ |
16 |
✓✓ |
11 |
const DicoValue * mapComputingCenter = dico.getMap("ComputingCenter"); |
17 |
✓✓ |
11 |
if(mapComputingCenter == NULL){return;} |
18 |
✓✓✓✓
|
7 |
computingCenter.setComputingCenterConnection(phoenix_get_string(*mapComputingCenter, "computing_center_connection", "")); |
19 |
✓✓✓✓
|
7 |
computingCenter.setRemoteWorkingDirectory(phoenix_get_string(*mapComputingCenter, "remote_working_directory", "")); |
20 |
✓✓✓✓
|
7 |
computingCenter.setRemoteContainerDirectory(phoenix_get_string(*mapComputingCenter, "remote_container_directory", "")); |
21 |
✓✓✓✓
|
7 |
computingCenter.setNotification(phoenix_get_string(*mapComputingCenter, "job_notification", "complete")); |
22 |
✓✓✓✓
|
7 |
computingCenter.setNotifyUser(phoenix_get_string(*mapComputingCenter, "notify_user", "")); |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
///Parse the Container from toml config |
26 |
|
|
/** @param[out] renderProject : internal representation of the RenderProject |
27 |
|
|
* @param dico : parsed DicoValue |
28 |
|
|
*/ |
29 |
|
11 |
void parseContainer(RenderProject & renderProject, const DicoValue & dico){ |
30 |
✓✓ |
11 |
const DicoValue * mapContainer = dico.getMap("Blender"); |
31 |
✓✓ |
11 |
if(mapContainer == NULL){return;} |
32 |
|
|
|
33 |
|
7 |
const VecDicoValue & vecContainer = mapContainer->getVecChild(); |
34 |
✓✓ |
21 |
for(VecDicoValue::const_iterator it(vecContainer.begin()); it != vecContainer.end(); ++it){ |
35 |
✓ |
28 |
Container container; |
36 |
✓✓✓✓
|
14 |
container.setUrl(phoenix_get_string(*it, "url", "")); |
37 |
✓✓✓✓
|
14 |
container.setContainerFilename(phoenix_get_string(*it, "container_filename", "blender.sif")); |
38 |
✓✓✓✓
|
14 |
container.setContainerRecipe(phoenix_get_string(*it, "container_recipe", "Singularity.ubuntu2204Blender")); |
39 |
✓✓✓✓
|
14 |
container.setContainerName(phoenix_get_string(*it, "container_name", "default")); |
40 |
|
|
|
41 |
✓✓✓✓
|
14 |
renderProject.getMapContainer()[container.getContainerName()] = container; |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
///Parse Scene from toml config |
46 |
|
|
/** @param[out] renderProject : internal representation of the RenderProject |
47 |
|
|
* @param dico : parsed DicoValue |
48 |
|
|
*/ |
49 |
|
11 |
void parseScene(RenderProject & renderProject, const DicoValue & dico, const std::string & workingDirectory){ |
50 |
✓✓ |
11 |
const DicoValue * mapScene = dico.getMap("Scene"); |
51 |
✓✓ |
11 |
if(mapScene == NULL){return;} |
52 |
|
7 |
std::cerr << "parseScene : workingDirectory = '"<<workingDirectory<<"'" << std::endl; |
53 |
|
7 |
const VecDicoValue & vecScene = mapScene->getVecChild(); |
54 |
✓✓ |
14 |
for(VecDicoValue::const_iterator it(vecScene.begin()); it != vecScene.end(); ++it){ |
55 |
✓ |
14 |
Scene scene; |
56 |
✓ |
7 |
scene.setWorkingDirectory(workingDirectory); |
57 |
✓✓✓✓
|
7 |
scene.setName(phoenix_get_string(*it, "name", "Scene")); |
58 |
✓✓✓✓
|
7 |
scene.setBlenderInputFile(phoenix_get_string(*it, "input_file", "")); |
59 |
✓✓✓✓
|
7 |
scene.setBlenderScene(phoenix_get_string(*it, "blender_scene", "")); |
60 |
✓✓✓ |
7 |
scene.setFirstFrame(phoenix_load_value_from_config(*it, "first_frame", 1)); |
61 |
✓✓✓ |
7 |
scene.setLastFrame(phoenix_load_value_from_config(*it, "last_frame", 1)); |
62 |
✓✓✓ |
7 |
scene.setStepFrame(phoenix_load_value_from_config(*it, "step_frame", 1)); |
63 |
✓✓✓✓
|
7 |
scene.setOutputRenderDirectory(phoenix_get_string(*it, "output_render_directory", "Output")); |
64 |
✓✓✓✓
|
7 |
scene.setRenderEngine(phoenix_get_string(*it, "render_engine", "BLENDER_EEVEE")); |
65 |
✓✓✓✓
|
7 |
scene.setCycleDevice(phoenix_get_string(*it, "cycle_device", "CUDA")); |
66 |
✓✓✓✓
|
7 |
scene.setOutputFormat(phoenix_get_string(*it, "output_format", "PNG")); |
67 |
✓✓✓✓
|
7 |
scene.setExtraOptions(phoenix_get_string(*it, "extra_options", "")); |
68 |
✓✓✓✓
|
7 |
scene.setContainerName(phoenix_get_string(*it, "container_name", "default")); |
69 |
✓✓✓ |
7 |
scene.setVecGpuType(phoenix_get_vecstring(*it, "gpu_type")); |
70 |
✓✓✓ |
7 |
scene.setRequestMemory(phoenix_load_value_from_config(*it, "request_memory", 2000)); |
71 |
✓✓✓✓
|
7 |
renderProject.getMapScene()[scene.getName()] = scene; |
72 |
|
|
} |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
///Parse the render project from toml config |
76 |
|
|
/** @param[out] renderProject : internal representation of the RenderProject |
77 |
|
|
* @param fileName : filename of the toml configuration to be used |
78 |
|
|
* @return true on success, false otherwise |
79 |
|
|
*/ |
80 |
|
4 |
bool parseRenderSubDirFromToml(RenderProject & renderProject, const std::string & fileName, const std::string & workingDirectory){ |
81 |
✓ |
8 |
DicoValue dico; |
82 |
✓✗✓ |
4 |
if(!parser_toml(dico, fileName)){ |
83 |
|
|
std::cerr << "parseRenderSubDirFromToml : cannot parse file '"<<fileName<<"'" << std::endl; |
84 |
|
|
return false; |
85 |
|
|
} |
86 |
✓ |
4 |
parseContainer(renderProject, dico); |
87 |
✓✓ |
4 |
parseComputingCenter(renderProject.getComputingCenter(), dico); |
88 |
✓ |
4 |
parseScene(renderProject, dico, workingDirectory); |
89 |
|
4 |
return true; |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
///Parse the render project from toml config |
93 |
|
|
/** @param[out] renderProject : internal representation of the RenderProject |
94 |
|
|
* @param dico : parsed DicoValue |
95 |
|
|
* @param fileName : filename of the toml configuration used to get dico |
96 |
|
|
* @return true on success, false otherwise |
97 |
|
|
*/ |
98 |
|
7 |
bool parseRenderProject(RenderProject & renderProject, const DicoValue & dico, const std::string & fileName){ |
99 |
✓✓ |
7 |
const DicoValue * mapProject = dico.getMap("Project"); |
100 |
✗✓✗✗ ✗✗✗✗ ✗✗ |
7 |
if(mapProject == NULL){std::cerr << "parseRenderProject : Missing [Project] definition in file '"<<fileName<<"'" << std::endl;return false;} |
101 |
✓✓✓✓
|
7 |
renderProject.setName(phoenix_get_string(*mapProject, "name", "ProjectName")); |
102 |
✓✓✓ |
7 |
renderProject.setVecSubDirectories(phoenix_get_vecstring(*mapProject, "sub_directories")); |
103 |
|
|
|
104 |
✓✓✓✓
|
7 |
renderProject.setSshExecutable(phoenix_get_string(*mapProject, "ssh_executable", "ssh")); |
105 |
✓✓✓✓
|
7 |
renderProject.setScpExecutable(phoenix_get_string(*mapProject, "scp_executable", "scp")); |
106 |
✓✓✓✓
|
7 |
renderProject.setCondorSubmitExecutable(phoenix_get_string(*mapProject, "condor_submit_executable", "condor_submit")); |
107 |
✓✓✓✓
|
7 |
renderProject.setApptainerExecutable(phoenix_get_string(*mapProject, "apptainer_executable", "apptainer")); |
108 |
✓✓✓✓
|
7 |
renderProject.setRsyncExecutable(phoenix_get_string(*mapProject, "rsync_executable", "rsync")); |
109 |
|
|
|
110 |
✓✓✓ |
7 |
renderProject.setVecExecutableCheckGpu(phoenix_get_vecstring(*mapProject, "vec_executable_check_gpu")); |
111 |
✓✓✗ |
7 |
if(renderProject.getVecExecutableCheckGpu().size() == 0lu){ |
112 |
✓✓✓ |
7 |
renderProject.getVecExecutableCheckGpu().push_back("nvidia-smi"); |
113 |
✓✓✓ |
7 |
renderProject.getVecExecutableCheckGpu().push_back("nvidia-smi -L"); |
114 |
|
|
} |
115 |
✓ |
7 |
std::string baseParentDir(getDirectory(fileName)); |
116 |
|
7 |
bool b(true); |
117 |
✓ |
7 |
std::vector<std::string> & vecSubDir = renderProject.getVecSubDirectories(); |
118 |
✓✓ |
11 |
for(std::vector<std::string>::iterator it(vecSubDir.begin()); it != vecSubDir.end(); ++it){ |
119 |
|
|
// std::string workingDirectory(getUnderPath(baseParentDir + "/" + (*it), renderProject.getSourceProjectDir() + "/")); |
120 |
|
|
// std::string workingDirectory(baseParentDir + "/" + (*it)); |
121 |
✓ |
4 |
std::string workingDirectory(*it); |
122 |
✗✓✗✗
|
4 |
if(workingDirectory == ""){workingDirectory = ".";} |
123 |
✓✓ |
4 |
b &= parseRenderSubDirFromToml(renderProject, workingDirectory + "/prender.toml", workingDirectory); |
124 |
|
|
} |
125 |
|
7 |
return true; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
///Parse the render project from toml config |
129 |
|
|
/** @param[out] renderProject : internal representation of the RenderProject |
130 |
|
|
* @param fileName : filename of the toml configuration to be used |
131 |
|
|
* @return true on success, false otherwise |
132 |
|
|
*/ |
133 |
|
7 |
bool parseRenderFromToml(RenderProject & renderProject, const std::string & fileName){ |
134 |
✓ |
14 |
DicoValue dico; |
135 |
✓✗✓ |
7 |
if(!parser_toml(dico, fileName)){ |
136 |
|
|
std::cerr << "parseRenderFromToml : cannot parse file '"<<fileName<<"'" << std::endl; |
137 |
|
|
return false; |
138 |
|
|
} |
139 |
✓✓ |
7 |
renderProject.setSourceProjectDir(getDirectory(fileName)); |
140 |
✓✓✓✓ ✓ |
7 |
std::cout << "parseRenderFromToml : project dir is '"+renderProject.getSourceProjectDir()+"'" << std::endl; |
141 |
✓ |
7 |
bool b(parseRenderProject(renderProject, dico, fileName)); |
142 |
✓ |
7 |
parseContainer(renderProject, dico); |
143 |
✓✓ |
7 |
parseComputingCenter(renderProject.getComputingCenter(), dico); |
144 |
✓✓ |
7 |
parseScene(renderProject, dico, "."); |
145 |
|
7 |
return b; |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
|