1 #include <boost/filesystem.hpp>
24 if (
pos_path.find(
".json") != std::string::npos ||
25 pos_path.find(
".JSON") != std::string::npos) {
32 dft_path.remove_filename();
34 "properties.calc.json";
35 if (fs::exists(dft_path)) {
36 return dft_path.string();
43 dft_path.remove_filename();
44 dft_path /=
"properties.calc.json";
45 if (fs::exists(dft_path)) {
46 return dft_path.string();
64 fs::create_directory(report_dir);
72 "initial_path",
"", [](
const Result &res) {
return res.
pos_path; });
104 "has_complete_data",
"", [](
const Result &res) {
return res.
has_data; });
109 "preexisting_data",
"",
115 "import_data",
"", [&](
const Result &res) {
122 "import_additional_files",
"",
128 "lattice_deformation_cost",
"",
139 "atomic_deformation_cost",
"",
191 "selected",
"", [](
const Result &res) {
return false; });
249 if (!fs::exists(p)) {
252 return std::distance(fs::directory_iterator(p), fs::directory_iterator());
274 return it->file_data == tfile_data;
277 return !tfile_data.
exists();
284 if (!fs::exists(p)) {
308 bool copy_additional_files)
const {
313 if (!fs::exists(p)) {
315 fs::create_directories(p);
321 if (origin_props_path.empty()) {
326 if (!copy_additional_files) {
327 log() <<
"cp " << origin_props_path <<
" " << p /
"properties.calc.json"
331 fs::copy_file(origin_props_path, p /
"properties.calc.json");
bool no_change(const std::string &configname) const
Check if 'properties.calc.json' file has not changed since last read.
bool has_existing_data_or_files(const std::string &to_configname) const
Database< Supercell > & db_supercell() const
Path to default calctype training_data directory for config.
bool has_existing_files(const std::string &to_configname) const
Return true if there are existing files in the traning_data directory for a particular configuration.
std::function< PropertiesDatabase &()> m_db_props_func
PropertiesDatabase & db_props() const
Uses primclex().settings().default_clex().calctype.
std::string calc_dir(const std::string configname) const
Path to default calctype training_data directory for config.
const PrimClex & primclex() const
static std::string resolve_struc_path(std::string pos_path, PrimClex const &_pclex)
Checks if pos_path can be used to resolve a properties.calc.json, and return its path Return path to ...
bool has_existing_data(const std::string &to_configname) const
Return true if there are existing files in the traning_data directory for a particular configuration.
void rm_files(const std::string &configname, bool dry_run) const
Remove existing files in the traning_data directory for a particular configuration.
void cp_files(ConfigIO::Result &res, bool dry_run, bool copy_additional_files) const
Copy files in the same directory as properties.calc.json into the traning_data directory for a partic...
double best_score(std::string to_configname) const
Best score of configurations that relaxed 'origin'->'to'.
virtual iterator end() const =0
End iterator over data entries.
double score(std::string origin) const
Score mapping 'origin'->'to'.
virtual iterator find_via_to(std::string to_configname) const =0
Return iterator to data entry that is the best mapping to specified config.
virtual iterator find_via_origin(std::string origin) const =0
Return iterator to data entry that is from the specified origin.
fs::path configuration_calc_dir(std::string configname, std::string calctype) const
Return directory containing properties.calc.json.
Interface class to check and/or store path and last_write_time of file on disk. Used to determine if ...
bool exists() const
checks path for existing file. Does not alter stored timestamp
std::string const & path() const
return stored path
void custom(const std::string &what)
PrimClex is the top-level data structure for a CASM project.
ClexDescription const & default_clex() const
Get default ClexDescription.
Represents a supercell of the primitive parent crystal structure.
std::string to_string(ENUM val)
Return string representation of enum class.
DB::Database< T > & db() const
ProjectSettings & settings()
const DirectoryStructure & dir() const
Access DirectoryStructure object. Throw if not set.
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
GenericDatumFormatter< std::string, Result > data_origin()
GenericDatumFormatter< double, Result > lattice_deformation_cost()
GenericDatumFormatter< bool, Result > import_additional_files()
GenericDatumFormatter< std::string, Result > final_path()
GenericDatumFormatter< double, Result > score()
GenericDatumFormatter< double, Result > best_score()
GenericDatumFormatter< bool, Result > has_data()
GenericDatumFormatter< bool, Result > import_data()
GenericDatumFormatter< double, Result > energy()
GenericDatumFormatter< bool, Result > preexisting_data()
GenericDatumFormatter< bool, Result > has_complete_data()
GenericDatumFormatter< bool, Result > selected()
Gives a 'selected' column, set all to false.
GenericDatumFormatter< bool, Result > is_new_config()
Gives a 'selected' column, set all to false.
GenericDatumFormatter< std::string, Result > to_configname()
GenericDatumFormatter< double, Result > atomic_deformation_cost()
void default_import_formatters(DataFormatterDictionary< Result > &dict, PropertiesDatabase &db_props)
Insert default formatters to dictionary, for 'casm import'.
GenericDatumFormatter< std::string, Result > initial_path()
GenericDatumFormatter< std::string, Result > fail_msg()
GenericDatumFormatter< bool, Result > is_best()
void default_update_formatters(DataFormatterDictionary< Result > &dict, PropertiesDatabase &db_props)
Insert default formatters to dictionary, for 'casm update'.
std::string create_report_dir(std::string report_dir)
Create a new report directory to avoid overwriting existing results.
static std::string _resolve_properties_path(std::string pos_path, PrimClex const &_pclex)
Return path to properties.calc.json that will be imported checking a couple possible locations relati...
std::string calc_properties_path(const ConfigType &config, std::string calctype="")
std::string pos_path(const ConfigType &config, std::string calctype="")
void recurs_rm_files(fs::path p, bool dry_run, Log &log)
Remove files recursively.
Index recurs_cp_files(const fs::path &from_dir, const fs::path &to_dir, bool dry_run, Log &log)
Copy files recursively, and returns a count of copied files.
INDEX_TYPE Index
For long integer indexing:
Data structure for mapping / import results.
MappedProperties properties
double const & scalar(std::string const &_name) const
bool has_scalar(std::string const &_name) const