Skip to content

Commit

Permalink
WIP: Introducing a RAII wrapper for jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlevidon committed Aug 12, 2024
1 parent 7a0d085 commit a347ce4
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions hpc/LoadBalancer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,45 @@ class JobManager
virtual ~JobManager() = default;
};

class FileBasedJob
class Job
{
public:
FileBasedJob()
{
virtual ~Job() = default;

}
virtual std::string getJobId() const = 0;
};

FileBaseJob~()
{

class FileBasedJob : public Job
{
public:
FileBasedJob(const std::string& command, std::function<std::string (const std::string&)> extract_job_id)
{
std::string command_output = getCommandOutput(command);
id = extract_job_id(command_output);
}

FileBasedJob(const FileBasedJob& other) = delete;

std::string getJobID() const
~FileBasedJob()
{
return job_id;

}
private:
std::string job_id;
protected:
std::string id;
};

template<typename T>
void deleteFileBased(T* t, std::string file_to_delete, std::string cancellation_command)
void deleteFileBased(T* t, std::string file_to_delete, std::string cancel_command)
{
delete t;
std::filesystem::remove(file_to_delete);
std::system(cancelation_command.c_str());
std::system(cancel_command.c_str());
}

// Basic idea:
// 1. Run some command to request a resource allocation on the HPC cluster.
// 2. Launch a model server in the resource allocation.
// 3. Retrieve the URL of the model server.
// 4. Connect to the model server using the URL.
class FileBasedJobManager : public JobManager
{
public:
Expand Down

0 comments on commit a347ce4

Please sign in to comment.