| 21 | |
| 22 | |
| 23 | class Pipeline: |
| 24 | def __init__(self, config: Config): |
| 25 | self.config = config |
| 26 | self._obj_map = instantiate_class_from_config(config) |
| 27 | self.pipeline_settings = self._obj_map["pipeline_settings"][0] |
| 28 | self.semantic_graph_context_generator = [ |
| 29 | self._obj_map["semantic_graph_context_generator"][i] |
| 30 | for i in range(len(self._obj_map["semantic_graph_context_generator"])) |
| 31 | ] |
| 32 | self.gnn_heads = [self._obj_map["gnn_heads"][i] for i in range(len(self._obj_map["gnn_heads"]))] |
| 33 | self.topic_model = self._obj_map["topic_model"][0] |
| 34 | |
| 35 | @classmethod |
| 36 | def from_config(cls, config: Config): |
| 37 | return cls(config) |
| 38 | |
| 39 | @classmethod |
| 40 | def from_yaml(cls, yaml_path): |
| 41 | config = Config.from_yaml(yaml_path) |
| 42 | return cls(config) |
| 43 | |
| 44 | def find_files_with_substring(self, root_dir, substring): |
| 45 | for dirpath, dirnames, filenames in os.walk(root_dir): |
| 46 | for filename in filenames: |
| 47 | if substring in filename: |
| 48 | yield os.path.join(dirpath, filename) |
| 49 | |
| 50 | def load_jsonl(self, filepaths): |
| 51 | res = [] |
| 52 | for filepath in filepaths: |
| 53 | with open(filepath, "r") as f: |
| 54 | for line in f: |
| 55 | res.append(json.loads(line)) |
| 56 | sents = [] |
| 57 | for r in res: |
| 58 | messages = r["conversation_history"] |
| 59 | reply = r["assistant_reply"] |
| 60 | sents.append(reply) |
| 61 | sents.append(messages[-2]["content"]) |
| 62 | data = pd.DataFrame(sents, columns=["query"]) |
| 63 | data["_id"] = data.index |
| 64 | return data |
| 65 | |
| 66 | def run(self, git_repo: str, repo_name: str) -> Tuple[Tuple[np.ndarray, np.ndarray], dict]: |
| 67 | """ |
| 68 | Run the pipeline.""" |
| 69 | # replace with lg.info |
| 70 | lg.info("Running pipeline...") |
| 71 | lg.info("Fetching repo...") |
| 72 | repo_folder, context_folder = clone_and_create_context_folder(git_repo, repo_name) |
| 73 | lg.info("Generating semantic graph context...") |
| 74 | |
| 75 | semantic_graph_context = [ |
| 76 | context_generator.decompose_repo( |
| 77 | repo_folder, |
| 78 | repo_name, |
| 79 | context_folder, |
| 80 | skip_graph_generation=self.pipeline_settings.config["skip_graph_creation"], |
nothing calls this directly
no outgoing calls
no test coverage detected