Skip to content

Commit 6c720d3

Browse files
committed
Fix the parsing of the composition file to JSON when required by Debug (admin) api
1 parent 4e34262 commit 6c720d3

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

python/cohorte/composer/top/composer.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
@Requires('_monitor', cohorte.monitor.SERVICE_MONITOR)
7171
@Requires('_node_starter', cohorte.SERVICE_NODE_STARTER)
7272
# ######### added by: Bassem D.
73-
@Requires('_parser', cohorte.composer.SERVICE_PARSER,
74-
optional=False)
73+
@Requires('_parser', cohorte.composer.SERVICE_PARSER, optional=False)
74+
@Requires('_reader', cohorte.SERVICE_FILE_READER, optional=False)
7575
@Property('_autostart', 'autostart', "True")
7676
@Property('_composition_filename', 'composition.filename', "composition.js")
7777
# #########
@@ -91,6 +91,7 @@ def __init__(self):
9191
self._node_starter = None
9292
# ######### added by: Bassem D.
9393
self._parser = None
94+
self._reader = None
9495
self._autostart = None
9596
self._composition_filename = None
9697
self._composition_json = None
@@ -130,8 +131,10 @@ def validate(self, context):
130131
if str(self._autostart).lower() in ("true", "yes"):
131132
# Load the composition
132133
try:
133-
composition = self._parser.load(
134-
self._composition_filename, "conf")
134+
self._composition_json = self._reader.load_file(
135+
self._composition_filename, "conf")
136+
composition = self._parser.parse_composition(
137+
self._composition_filename, self._composition_json)
135138
if composition:
136139
_logger.info("Loading composition...")
137140
uid = self.start(composition)
@@ -228,11 +231,5 @@ def stop(self, uid):
228231
def get_composition_json(self):
229232
"""
230233
Gets composition JSON file raw content
231-
"""
232-
if not self._composition_json:
233-
# parse the composition file
234-
conf_dir = os.path.join(self._context.get_property("cohorte.base"), "conf")
235-
file_name = os.path.join(conf_dir, self._composition_filename)
236-
with open(file_name, "r") as comp_json_file:
237-
self._composition_json = json.load(comp_json_file)
234+
"""
238235
return self._composition_json

0 commit comments

Comments
 (0)