From f5058fbcdd03f634567e8bb196ff20e0cd36d368 Mon Sep 17 00:00:00 2001 From: JayGhiya Date: Wed, 23 Oct 2024 16:32:28 +0530 Subject: [PATCH] feat: added common lib for ingestion and query utility --- .../configuration/release-please-config.json | 6 ++++++ .github/workflows/python_build.yaml | 1 + .../python_publish_release_management.yaml | 4 ++-- .../__init__.py | 0 .../graph_models/__init__.py | 0 .../graph_models/base_models.py | 17 +++++++++++++++++ .../graph_models/class_node.py | 11 +++++++++++ .../graph_models/codebase_node.py | 18 ++++++++++++++++++ .../graph_models/method_node.py | 9 +++++++++ .../graph_models/package_node.py | 12 ++++++++++++ 10 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/__init__.py create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/__init__.py create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/base_models.py create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/class_node.py create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/codebase_node.py create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/method_node.py create mode 100644 unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/package_node.py diff --git a/.github/configuration/release-please-config.json b/.github/configuration/release-please-config.json index 4b73c79..60400fa 100644 --- a/.github/configuration/release-please-config.json +++ b/.github/configuration/release-please-config.json @@ -11,6 +11,12 @@ "changelog-path": "CHANGELOG.md", "include-component-in-tag": true, "component": "unoplat-code-confluence-query-engine" + }, + "unoplat-code-confluence-commons": { + "release-type": "python", + "changelog-path": "CHANGELOG.md", + "include-component-in-tag": true, + "component": "unoplat-code-confluence-commons" } } } diff --git a/.github/workflows/python_build.yaml b/.github/workflows/python_build.yaml index dcc67a7..7e0517a 100644 --- a/.github/workflows/python_build.yaml +++ b/.github/workflows/python_build.yaml @@ -8,6 +8,7 @@ on: paths: - 'unoplat-code-confluence/**' - 'unoplat-code-confluence-query-engine/**' + - 'unoplat-code-confluence-commons/**' jobs: prepare-matrix: runs-on: ubuntu-latest diff --git a/.github/workflows/python_publish_release_management.yaml b/.github/workflows/python_publish_release_management.yaml index 319d800..2cee51c 100644 --- a/.github/workflows/python_publish_release_management.yaml +++ b/.github/workflows/python_publish_release_management.yaml @@ -77,11 +77,11 @@ jobs: with: poetry-version: "1.8.3" - name: Build poetry - working-directory: unoplat-code-confluence + working-directory: ${{ matrix.path }} run: poetry build -f wheel # - name: Publish package distributions to PyPI # uses: pypa/gh-action-pypi-publish@release/v1 # with: - # packages-dir: unoplat-code-confluence/dist + # packages-dir: ${{ matrix.path }}/dist diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/__init__.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/__init__.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/base_models.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/base_models.py new file mode 100644 index 0000000..e942443 --- /dev/null +++ b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/base_models.py @@ -0,0 +1,17 @@ +from neomodel import ( + StructuredNode, + StringProperty, + JSONProperty, + ArrayProperty, + StructuredRel +) + +class BaseNode(StructuredNode): + """Base node with common properties""" + qualified_name = StringProperty(unique_index=True, required=True) + objective_embedding = ArrayProperty(default=[]) + implementation_embedding = ArrayProperty(default=[]) + +class ContainsRelationship(StructuredRel): + """Relationship for representing containment between nodes""" + pass diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/class_node.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/class_node.py new file mode 100644 index 0000000..4727719 --- /dev/null +++ b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/class_node.py @@ -0,0 +1,11 @@ +from .base_models import BaseNode, ContainsRelationship +from neomodel import RelationshipFrom, RelationshipTo, StringProperty,ZeroOrMore,One + +class Class(BaseNode): + """Represents a class in a package""" + node_name = StringProperty(required=True) + node_summary = StringProperty(default="") + node_objective = StringProperty(default="") + # Class relationships + package = RelationshipFrom('Package', 'CONTAINS', model=ContainsRelationship, cardinality=One) + methods = RelationshipTo('Method', 'CONTAINS', model=ContainsRelationship, cardinality=ZeroOrMore) diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/codebase_node.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/codebase_node.py new file mode 100644 index 0000000..4788ae3 --- /dev/null +++ b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/codebase_node.py @@ -0,0 +1,18 @@ +from neomodel import ( + StringProperty, + RelationshipTo, + RelationshipFrom, + ZeroOrMore, + One +) +from .base_models import BaseNode, ContainsRelationship + +class Codebase(BaseNode): + """Represents a codebase in the system""" + codebase_summary = StringProperty(default="") + codebase_objective = StringProperty(default="") + # One codebase can contain multiple packages + packages = RelationshipTo('Package', 'CONTAINS', model=ContainsRelationship, cardinality=ZeroOrMore) + + + diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/method_node.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/method_node.py new file mode 100644 index 0000000..643de08 --- /dev/null +++ b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/method_node.py @@ -0,0 +1,9 @@ +from .base_models import BaseNode, ContainsRelationship +from neomodel import RelationshipFrom, StringProperty,One + +class Method(BaseNode): + """Represents a method in a class""" + function_name = StringProperty(required=True) + function_summary = StringProperty(default="") + # Method relationships + class_ = RelationshipFrom('Class', 'CONTAINS', model=ContainsRelationship, cardinality=One) diff --git a/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/package_node.py b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/package_node.py new file mode 100644 index 0000000..9069d60 --- /dev/null +++ b/unoplat-code-confluence-commons/unoplat_code_confluence_commons/graph_models/package_node.py @@ -0,0 +1,12 @@ +from .base_models import BaseNode, ContainsRelationship +from neomodel import RelationshipFrom, RelationshipTo, StringProperty,ZeroOrMore,One + +class Package(BaseNode): + """Represents a package in the codebase""" + package_objective = StringProperty(required=True) + package_summary = StringProperty(required=True) + # Package relationships + codebase = RelationshipFrom('Codebase', 'CONTAINS', model=ContainsRelationship, cardinality=One) + sub_packages = RelationshipTo('Package', 'CONTAINS', model=ContainsRelationship, cardinality=ZeroOrMore) + parent_package = RelationshipFrom('Package', 'CONTAINS', model=ContainsRelationship, cardinality=ZeroOrMore) + classes = RelationshipTo('Class', 'CONTAINS', model=ContainsRelationship, cardinality=ZeroOrMore)