-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into COG-475-local-file-endpoint-deletion
- Loading branch information
Showing
7 changed files
with
847 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
|
||
import aiofiles | ||
|
||
import cognee.modules.ingestion as ingestion | ||
from cognee.infrastructure.engine import DataPoint | ||
from cognee.modules.data.methods import get_datasets | ||
from cognee.modules.data.methods.get_dataset_data import get_dataset_data | ||
from cognee.modules.data.methods.get_datasets_by_name import \ | ||
get_datasets_by_name | ||
from cognee.modules.data.models import Data | ||
from cognee.modules.data.operations.write_metadata import write_metadata | ||
from cognee.modules.ingestion.data_types import BinaryData | ||
from cognee.modules.users.methods import get_default_user | ||
from cognee.shared.CodeGraphEntities import Repository | ||
|
||
|
||
async def get_non_py_files(repo_path): | ||
"""Get files that are not .py files and their contents""" | ||
if not os.path.exists(repo_path): | ||
return {} | ||
|
||
IGNORED_PATTERNS = { | ||
'.git', '__pycache__', '*.pyc', '*.pyo', '*.pyd', | ||
'node_modules', '*.egg-info' | ||
} | ||
|
||
def should_process(path): | ||
return not any(pattern in path for pattern in IGNORED_PATTERNS) | ||
|
||
non_py_files_paths = [ | ||
os.path.join(root, file) | ||
for root, _, files in os.walk(repo_path) for file in files | ||
if not file.endswith(".py") and should_process(os.path.join(root, file)) | ||
] | ||
return non_py_files_paths | ||
|
||
|
||
async def get_data_list_for_user(_, dataset_name, user): | ||
# Note: This method is meant to be used as a Task in a pipeline. | ||
# By the nature of pipelines, the output of the previous Task will be passed as the first argument here, | ||
# but it is not needed here, hence the "_" input. | ||
datasets = await get_datasets_by_name(dataset_name, user.id) | ||
data_documents: list[Data] = [] | ||
for dataset in datasets: | ||
data_docs: list[Data] = await get_dataset_data(dataset_id=dataset.id) | ||
data_documents.extend(data_docs) | ||
return data_documents |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import argparse | ||
import asyncio | ||
|
||
from cognee.api.v1.cognify.code_graph_pipeline import run_code_graph_pipeline | ||
|
||
|
||
async def main(repo_path): | ||
async for result in await run_code_graph_pipeline(repo_path): | ||
async def main(repo_path, include_docs): | ||
async for result in run_code_graph_pipeline(repo_path, include_docs): | ||
print(result) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--repo-path", type=str, required=True, help="Path to the repository") | ||
parser.add_argument("--repo_path", type=str, required=True, help="Path to the repository") | ||
parser.add_argument("--include_docs", type=bool, default=True, help="Whether or not to process non-code files") | ||
args = parser.parse_args() | ||
asyncio.run(main(args.repo_path)) | ||
|
||
asyncio.run(main(args.repo_path, args.include_docs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.