Skip to content

Commit 01e2133

Browse files
committed
code: remove job/profile json_description
1 parent 780daec commit 01e2133

File tree

6 files changed

+2
-69
lines changed

6 files changed

+2
-69
lines changed

Diff for: src/job_submitter.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ static string submit_workflow_task_as_job(BatsimContext *context, string workflo
282282
DelayProfileData * data = new DelayProfileData;
283283
data->delay = task->execution_time;
284284
profile->data = data;
285-
profile->json_description = std::string() + "{" +
286-
"\"type\": \"delay\", "+
287-
"\"delay\": " + std::to_string(task->execution_time) +
288-
"}";
289285
string profile_name = workflow_name + "_" + task->id; // Create a profile name
290286
profile->name = profile_name;
291287
context->workloads.at(workload_name)->profiles->add_profile(profile_name, profile);

Diff for: src/jobs.cpp

-52
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
#include <fstream>
1111
#include <streambuf>
1212
#include <algorithm>
13-
#include <regex>
1413

1514
#include <boost/algorithm/string.hpp>
1615
#include <boost/algorithm/string/join.hpp>
1716

1817
#include <simgrid/s4u.hpp>
1918

2019
#include <rapidjson/document.h>
21-
#include <rapidjson/writer.h>
22-
#include <rapidjson/stringbuffer.h>
2320

2421
#include "profiles.hpp"
2522

@@ -407,55 +404,6 @@ JobPtr Job::from_json(const rapidjson::Value & json_desc,
407404
error_prefix.c_str(), profile_name.c_str(), j->id.to_string().c_str());
408405
j->profile = workload->profiles->at(profile_name);
409406

410-
// Let's get the JSON string which originally described the job
411-
// (to conserve potential fields unused by Batsim)
412-
rapidjson::StringBuffer buffer;
413-
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
414-
json_desc.Accept(writer);
415-
416-
// Let's replace the job ID by its WLOAD!NUMBER counterpart if needed
417-
// in the json raw description
418-
string json_description_tmp(buffer.GetString(), buffer.GetSize());
419-
/// @cond DOXYGEN_FAILS_PARSING_THIS_REGEX
420-
std::regex r(R"("id"\s*:\s*(?:"*[^(,|})]*"*)\s*)");
421-
/// @endcond
422-
string replacement_str = "\"id\":\"" + j->id.to_string() + "\"";
423-
// XBT_INFO("Before regexp: %s", json_description_tmp.c_str());
424-
j->json_description = std::regex_replace(json_description_tmp, r, replacement_str);
425-
426-
// Let's check that the new description is a valid JSON string
427-
rapidjson::Document check_doc;
428-
check_doc.Parse(j->json_description.c_str());
429-
xbt_assert(!check_doc.HasParseError(),
430-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart:"
431-
"The output string '%s' is not valid JSON.", j->json_description.c_str());
432-
xbt_assert(check_doc.IsObject(),
433-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
434-
"The output string '%s' is not valid JSON.", j->json_description.c_str());
435-
xbt_assert(check_doc.HasMember("id"),
436-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
437-
"The output JSON '%s' has no 'id' field.", j->json_description.c_str());
438-
xbt_assert(check_doc["id"].IsString(),
439-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
440-
"The output JSON '%s' has a non-string 'id' field.", j->json_description.c_str());
441-
xbt_assert(check_doc.HasMember("subtime") && check_doc["subtime"].IsNumber(),
442-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
443-
"The output JSON '%s' has no 'subtime' field (or it is not a number)",
444-
j->json_description.c_str());
445-
xbt_assert((check_doc.HasMember("walltime") && check_doc["walltime"].IsNumber())
446-
|| (!check_doc.HasMember("walltime")),
447-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
448-
"The output JSON '%s' has no 'walltime' field (or it is not a number)",
449-
j->json_description.c_str());
450-
xbt_assert(check_doc.HasMember("res") && check_doc["res"].IsInt(),
451-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
452-
"The output JSON '%s' has no 'res' field (or it is not an integer)",
453-
j->json_description.c_str());
454-
xbt_assert(check_doc.HasMember("profile") && check_doc["profile"].IsString(),
455-
"A problem occured when replacing the job_id by its WLOAD!job_name counterpart: "
456-
"The output JSON '%s' has no 'profile' field (or it is not a string)",
457-
j->json_description.c_str());
458-
459407
XBT_DEBUG("Job '%s' Loaded", j->id.to_string().c_str());
460408
return j;
461409
}

Diff for: src/jobs.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ struct Job
209209
Workload * workload = nullptr; //!< The workload the job belongs to
210210
JobIdentifier id; //!< The job unique identifier
211211
BatTask * task = nullptr; //!< The root task be executed by this job (profile instantiation).
212-
std::string json_description; //!< The JSON description of the job
213212
std::set<simgrid::s4u::ActorPtr> execution_actors; //!< The actors involved in running the job
214213
std::deque<std::string> incoming_message_buffer; //!< The buffer for incoming messages from the scheduler.
215214

Diff for: src/jobs_execution.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ int execute_task(
116116
return execute_trace_replay(btask, alloc_placement, remaining_time, context);
117117
}
118118
else
119-
xbt_die("Cannot execute job %s: the profile '%s' is of unknown type: %s",
120-
job->id.to_cstring(), job->profile->name.c_str(), profile->json_description.c_str());
119+
xbt_die("Cannot execute job %s: the profile '%s' is of unknown type (%d)",
120+
job->id.to_cstring(), job->profile->name.c_str(), (int)profile->type);
121121

122122
return 1;
123123
}

Diff for: src/profiles.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include <xbt/asserts.h>
1515

1616
#include <rapidjson/document.h>
17-
#include <rapidjson/writer.h>
18-
#include <rapidjson/stringbuffer.h>
1917

2018
using namespace std;
2119
using namespace rapidjson;
@@ -633,13 +631,6 @@ ProfilePtr Profile::from_json(const std::string & profile_name,
633631
profile_name.c_str(), profile_type.c_str());
634632
}
635633

636-
637-
// Let's get the JSON string which describes the profile (to conserve potential fields unused by Batsim)
638-
rapidjson::StringBuffer buffer;
639-
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
640-
json_desc.Accept(writer);
641-
profile->json_description = string(buffer.GetString(), buffer.GetSize());
642-
643634
return profile;
644635
}
645636

Diff for: src/profiles.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct Profile
4747

4848
ProfileType type; //!< The type of the profile
4949
void * data; //!< The associated data
50-
std::string json_description; //!< The JSON description of the profile
5150
std::string name; //!< the profile unique name
5251
int return_code = 0; //!< The return code of this profile's execution (SUCCESS == 0)
5352

0 commit comments

Comments
 (0)