22 #include <tensor/jobs.h>
23 #include <tensor/sdf.h>
28 std::string NumberToString ( T Number )
39 std::ostringstream ss;
45 dataset_name(
const std::string &base,
int jobid)
47 return base +
"/" + NumberToString(jobid);
51 Job::open_dataset(
const std::string &filename)
const
53 if (sdf::file_exists(filename)) {
54 if (!sdf::isdir(filename)) {
55 std::cerr <<
"Cannot create Job dataset on existing file\n";
62 sdf::make_directory(filename);
63 if (!sdf::file_exists(filename)) {
64 std::cerr <<
"Cannot create Job dataset\n";
68 std::string dataset_record_name = dataset_name(filename, current_job());
69 sdf::OutDataFile *output;
70 if (sdf::file_exists(dataset_record_name)) {
71 std::cout <<
"File " << dataset_record_name <<
" already exists" << std::endl;
74 output =
new sdf::OutDataFile(dataset_record_name,
75 sdf::DataFile::SDF_PARANOID);
77 return dataset(output);
81 Job::dataset_record_exists(
const std::string &filename)
const
83 return sdf::file_exists(dataset_name(filename, current_job()));