Skip to content

Commit

Permalink
Each not numeric task can have an own extra environment.
Browse files Browse the repository at this point in the history
Closes #513.
  • Loading branch information
timurhai committed Jul 2, 2021
1 parent 4834bac commit 3f9e11b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions afanasy/python/af.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def setFiles(self, files, TransferToServer=True):
afile = Pathmap.toServer(afile)
self.data["files"].append(afile)

def setEnv(self, i_name, i_value):
"""Missing DocString
:param i_name:
:param i_value:
:return:
"""
if "environment" not in self.data:
self.data["environment"] = dict()

self.data["environment"][i_name] = i_value


class Block:
"""Missing DocString
Expand Down
2 changes: 2 additions & 0 deletions afanasy/src/libafanasy/blockdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ TaskExec *BlockData::genTask(int num) const
taskExec->setTaskCommand(m_tasks_data[num]->getCommand());
taskExec->setTaskFiles(m_tasks_data[num]->getFiles());
taskExec->m_custom_data_task = m_tasks_data[num]->getCustomData();
if (m_tasks_data[num]->hasEnvironment())
taskExec->joinEnvironment(m_tasks_data[num]->getEnvironment());
}

return taskExec;
Expand Down
3 changes: 3 additions & 0 deletions afanasy/src/libafanasy/taskdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ void TaskData::jsonRead( const JSON & i_object)
jr_string("name", m_name, i_object);
jr_string("command", m_command, i_object);
jr_stringvec("files", m_files, i_object);

jr_stringmap("environment", m_environment, i_object);

//jr_string("depend_mask", m_depend_mask, i_object);
//jr_string("custom_data", m_custom_data, i_object);
}
Expand Down
4 changes: 3 additions & 1 deletion afanasy/src/libafanasy/taskdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ class TaskData : public Af
inline const std::string & getDependMask() const { return m_depend_mask; }
inline const std::string & getCustomData() const { return m_custom_data; }
inline const std::vector<std::string> & getFiles() const { return m_files;}
inline const std::map<std::string, std::string> & getEnvironment() const {return m_environment;}

inline bool hasFiles() const { return m_files.size(); } ///< Whether files are set.
inline bool hasDependMask() const { return m_depend_mask.size(); } ///< Whether depend mask is set.
inline bool hasCustomData() const { return m_custom_data.size();} ///< Whether files are set.

inline bool hasEnvironment() const { return m_environment.size();}
bool checkDependMask( const std::string & str);

void jsonRead( const JSON & i_object);
Expand All @@ -41,6 +42,7 @@ class TaskData : public Af
std::string m_depend_mask; ///< Dependences.
std::string m_custom_data; ///< Some custom data.
std::vector<std::string> m_files; ///< Files.
std::map<std::string, std::string> m_environment; ///< Task extra environment.

protected:
/// Read or write task data.
Expand Down
3 changes: 3 additions & 0 deletions afanasy/src/libafanasy/taskexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ class TaskExec : public Af
inline void setTaskCommand(const std::string & i_str ) {m_command_task = i_str;}
inline void setTaskFiles( const std::vector<std::string> & i_vec) {m_files_task = i_vec;}

inline void joinEnvironment(const std::map<std::string, std::string> & i_env);
{for (auto const& it : i_env) m_environment[it.first] = it.second;}

inline void setHostNames( const std::list<std::string> & names) { m_multihost_names = names;}
inline const std::list<std::string> & getMultiHostsNames() const { return m_multihost_names; }

Expand Down

0 comments on commit 3f9e11b

Please sign in to comment.