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

make output folder if it does not exist #275

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ jobs:
{name: "Windows", os: "windows-latest", shell: "msys2", compiler: "g++"},
]
projects: [
{project: "template", name: "PhysiCell Template", binary: "project", max_time: 120, config: "config/PhysiCell_settings.xml", output_folder: "output"},
{project: "template_BM", name: "PhysiBoSS Template", binary: "project", max_time: 120, config: "config/PhysiCell_settings.xml", output_folder: "output"},
{project: "physiboss-cell-lines-sample", name: "PhysiBoSS Cell Lines", binary: "PhysiBoSS_Cell_Lines", max_time: 120, config: "config/PhysiCell_settings.xml", output_folder: "output"},
{project: "physimess-sample", name: "PhysiMeSS Sample", binary: "project", config: "config/Fibre_Degradation/mymodel_matrix_degradation.xml", max_time: 120, output_folder: ""},
{project: "physiboss-tutorial", name: "PhysiBoSS Tutorial", binary: "project", config: "config/cell_cycle/PhysiCell_settings.xml", max_time: 300, output_folder: "output"},
{project: "worm-sample", name: "PhysiCell worm", binary: "worm", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: "output"},
{project: "virus-macrophage-sample", name: "Virus Macrophage", binary: "virus-sample", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: "output"},
{project: "mechano-sample", name: "PhysiCell Mechano", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: "output"},
{project: "cancer-biorobots-sample", name: "PhysiCell Cancer Biorobots", binary: "cancer_biorobots", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "biorobots-sample", name: "PhysiCell Biorobots", binary: "biorobots", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "celltypes3-sample", name: "PhysiCell Celltypes3", binary: "celltypes3", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "custom-division-sample", name: "PhysiCell custom division", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "interaction-sample", name: "PhysiCell interactions", binary: "interaction_demo", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "pred-prey-farmer", name: "PhysiCell prey predator", binary: "pred_prey", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "rules-sample", name: "PhysiCell rules sample", binary: "rules_sample", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""},
{project: "asymmetric-division-sample", name: "PhysiCell asymmetric division", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, output_folder: ""}
{project: "template", name: "PhysiCell Template", binary: "project", max_time: 120, config: "config/PhysiCell_settings.xml", compare_svgs: true, output_folder: "output"},
{project: "template_BM", name: "PhysiBoSS Template", binary: "project", max_time: 120, config: "config/PhysiCell_settings.xml", compare_svgs: true, output_folder: "output"},
{project: "physiboss-cell-lines-sample", name: "PhysiBoSS Cell Lines", binary: "PhysiBoSS_Cell_Lines", max_time: 120, config: "config/PhysiCell_settings.xml", compare_svgs: true, output_folder: "output"},
{project: "physimess-sample", name: "PhysiMeSS Sample", binary: "project", config: "config/Fibre_Degradation/mymodel_matrix_degradation.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "physiboss-tutorial", name: "PhysiBoSS Tutorial", binary: "project", config: "config/cell_cycle/PhysiCell_settings.xml", max_time: 300, compare_svgs: true, output_folder: "output"},
{project: "worm-sample", name: "PhysiCell worm", binary: "worm", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: true, output_folder: "output"},
{project: "virus-macrophage-sample", name: "Virus Macrophage", binary: "virus-sample", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: true, output_folder: "output"},
{project: "mechano-sample", name: "PhysiCell Mechano", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: true, output_folder: "output"},
{project: "cancer-biorobots-sample", name: "PhysiCell Cancer Biorobots", binary: "cancer_biorobots", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "biorobots-sample", name: "PhysiCell Biorobots", binary: "biorobots", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "celltypes3-sample", name: "PhysiCell Celltypes3", binary: "celltypes3", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "custom-division-sample", name: "PhysiCell custom division", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "interaction-sample", name: "PhysiCell interactions", binary: "interaction_demo", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "pred-prey-farmer", name: "PhysiCell prey predator", binary: "pred_prey", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "template", name: "PhysiCell Template - make output folder", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, "output_folder": "test/create/output/folder"},
{project: "rules-sample", name: "PhysiCell rules sample", binary: "rules_sample", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"},
{project: "asymmetric-division-sample", name: "PhysiCell asymmetric division", binary: "project", config: "config/PhysiCell_settings.xml", max_time: 120, compare_svgs: false, output_folder: "output"}
]

name: Testing ${{ matrix.projects.name }} on ${{ matrix.os.name }}
Expand All @@ -59,9 +60,9 @@ jobs:

- name: Run ${{ matrix.projects.name }} project
run: |
python beta/test_run_sample.py ${{ matrix.projects.binary }} ${{ matrix.projects.config }} ${{ matrix.projects.max_time }}
python beta/test_run_sample.py ${{ matrix.projects.binary }} ${{ matrix.projects.config }} ${{ matrix.projects.max_time }} ${{ matrix.projects.output_folder }}

- name: Check ${{ matrix.projects.name }} project simulation results
if: matrix.projects.output_folder != ''
if: matrix.projects.compare_svgs
run: |
python beta/test_diff_svg.py ${{ matrix.projects.output_folder }} tests/cases/output_${{ matrix.projects.project }}
python beta/test_diff_svg.py output tests/cases/output_${{ matrix.projects.project }}
8 changes: 7 additions & 1 deletion beta/test_run_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def disable_automated_spring_adhesions(root):
if spring_adhesion is not None:
spring_adhesion.text = "true"

def run_sample(myexec, xml_file, max_time):
def set_output_folder(root, folder):
if folder == "":
return
root.find(".//save//folder").text = folder

def run_sample(myexec, xml_file, max_time, output_folder):

print("\n\n------------ ",myexec, " ----------------------------------")
# update max_time and omp_num_threads (=1)
Expand All @@ -42,6 +47,7 @@ def run_sample(myexec, xml_file, max_time):
make_deathmodel_deterministic(root)
make_chemotaxis_deterministic(root)
disable_automated_spring_adhesions(root)
set_output_folder(root, output_folder)

tree.write(xml_file)
subprocess.run(["cat", xml_file])
Expand Down
42 changes: 42 additions & 0 deletions modules/PhysiCell_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
###############################################################################
*/

#include <sys/stat.h>
#include "./PhysiCell_settings.h"

using namespace BioFVM;
Expand Down Expand Up @@ -108,6 +109,8 @@ bool load_PhysiCell_config_file( std::string filename )

parameters.read_from_pugixml( physicell_config_root );

create_output_directory( PhysiCell_settings.folder );

return true;
}

Expand Down Expand Up @@ -320,6 +323,45 @@ void PhysiCell_Settings::read_from_pugixml( void )
return;
}

bool create_directories(const std::string &path)
{
std::vector<std::string> directories;
size_t pos = 0;
std::string currentPath;

while ((pos = path.find_first_of("/\\", pos)) != std::string::npos) {
currentPath = path.substr(0, pos++);
if (!create_directory(currentPath)) {
return false;
}
}
return create_directory(path);
}

bool create_directory(const std::string &path)
{
#if defined(__MINGW32__) || defined(__MINGW64__)
bool success = mkdir(path.c_str()) == 0;
#else
bool success = mkdir(path.c_str(), 0755) == 0;
#endif
return success || errno == EEXIST;
}

void create_output_directory(const std::string& path)
{
if (!create_directories(path))
{
std::cout << "ERROR: Could not create output directory " << path << " ! Quitting." << std::endl;
exit(-1);
}
}

void create_output_directory(void)
{
create_output_directory(PhysiCell_settings.folder);
}

PhysiCell_Globals PhysiCell_globals;

/* parameters functions */
Expand Down
6 changes: 6 additions & 0 deletions modules/PhysiCell_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ class PhysiCell_Settings
void read_from_pugixml( void );
};

bool create_directories(const std::string &path);
bool create_directory(const std::string &path);

void create_output_directory(const std::string& path);
void create_output_directory(void);

class PhysiCell_Globals
{
private:
Expand Down
2 changes: 1 addition & 1 deletion sample_projects/cancer_biorobots/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/cancer_immune/main-cancer_immune_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/heterogeneity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/interactions/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/mechano/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/pred_prey_farmer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/rules_sample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/template/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/virus_macrophage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects/worm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects_intracellular/boolean/template_BM/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion sample_projects_intracellular/boolean/tutorial/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/custom_DCs_2substrates/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/custom_voxel_values/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main( int argc, char* argv[] )
}
if( !XML_status )
{ exit(-1); }

// copy config file to output directry
system( copy_command );

Expand Down
Loading