MCPcopy Create free account
hub / github.com/modelscope/ms-agent / execute_code

Method execute_code

projects/code_genesis/workflow/coding.py:645–704  ·  view source on GitHub ↗
(self, inputs, **kwargs)

Source from the content-addressed store, hash-verified

643 await programmer.run(messages)
644
645 async def execute_code(self, inputs, **kwargs):
646 await self._init_lsp_servers()
647 with open(os.path.join(self.output_dir, 'topic.txt')) as f:
648 topic = f.read()
649 with open(os.path.join(self.output_dir, 'user_story.txt')) as f:
650 user_story = f.read()
651 with open(os.path.join(self.output_dir, 'framework.txt')) as f:
652 framework = f.read()
653 with open(os.path.join(self.output_dir, 'protocol.txt')) as f:
654 protocol = f.read()
655 with open(os.path.join(self.output_dir, 'file_order.txt')) as f:
656 file_order = f.read()
657
658 file_orders = self.construct_file_orders()
659 file_relation = OrderedDict()
660 self.refresh_file_status(file_relation)
661 shutil.rmtree(
662 os.path.join(self.output_dir, 'locks'), ignore_errors=True)
663
664 for idx, files in enumerate(file_orders):
665 while True:
666 files = self.filter_done_files(files)
667 files = self.find_description(files)
668 self.construct_file_information(file_relation)
669 if not files:
670 break
671
672 if idx == 0:
673 last_batch = 'You are the first batch.'
674 next_batch = '\n'.join(file_orders[idx + 1])
675 if idx == len(file_orders) - 1:
676 last_batch = '\n'.join(file_orders[idx - 1])
677 next_batch = 'You are the last batch.'
678 else:
679 last_batch = '\n'.join(file_orders[idx - 1])
680 next_batch = '\n'.join(file_orders[idx + 1])
681
682 tasks = [
683 self.write_code(
684 topic,
685 user_story,
686 framework,
687 protocol,
688 file_order,
689 name,
690 description,
691 index=idx,
692 last_batch=last_batch,
693 siblings='\n'.join(set(files) - {name}),
694 next_batch=next_batch)
695 for name, description in files.items()
696 ]
697
698 await asyncio.gather(*tasks, return_exceptions=True)
699
700 self.refresh_file_status(file_relation)
701
702 self.construct_file_information(file_relation)

Callers

nothing calls this directly

Calls 8

_init_lsp_serversMethod · 0.95
construct_file_ordersMethod · 0.95
refresh_file_statusMethod · 0.95
filter_done_filesMethod · 0.95
find_descriptionMethod · 0.95
write_codeMethod · 0.95
_cleanup_lsp_serversMethod · 0.95

Tested by

no test coverage detected