Skip to content

Commit

Permalink
chore: change package name
Browse files Browse the repository at this point in the history
  • Loading branch information
Khushiyant committed Apr 28, 2024
1 parent f315c02 commit 7b9666a
Show file tree
Hide file tree
Showing 30 changed files with 157 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "quasarx"
name = "quasarpy"
version = "0.1.0"
description = "Quasar is python package that can be used for smell detection along with detailed report in various formats such as html, pdf, etc."
authors = ["Khushiyant <khushiyant2002@gmail.com>"]
Expand Down
14 changes: 7 additions & 7 deletions quasarx/cli/__init__.py → quasar/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import click
import os
from datetime import datetime
from quasarx._version import __version__ as _version
from quasarx.utils import ASCII_ART
from quasarx.utils import analyse
from quasarx.algorithm.detector import MainDetector, detect_smell
from quasarx.handler.issue import IssueHandler, Repository
from quasarx.utils.redis_server import generate_report, RedisConfig
from quasarpy._version import __version__ as _version
from quasarpy.utils import ASCII_ART
from quasarpy.utils import analyse
from quasarpy.algorithm.detector import MainDetector, detect_smell
from quasarpy.handler.issue import IssueHandler, Repository
from quasarpy.utils.redis_server import generate_report, RedisConfig
import asyncio
from quasarx.algorithm import LLM, LLMConfig
from quasarpy.algorithm import LLM, LLMConfig

class ASCIICommandClass(click.Group):
def get_help(self, ctx):
Expand Down
6 changes: 3 additions & 3 deletions quasarx/__init__.py → quasarpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'''This module contains the main() function, which is the entry point for the
command line interface.'''
from dotenv import load_dotenv
from quasarx.cli import cli
from quasarx.utils import logger
from quasarx._version import __version__ as _version
from quasarpy.cli import cli
from quasarpy.utils import logger
from quasarpy._version import __version__ as _version

__version__ = _version

Expand Down
2 changes: 1 addition & 1 deletion quasarx/__main__.py → quasarpy/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module allowing for ``python -m quasar ...``."""
from quasarx import main
from quasarpy import main

main()
File renamed without changes.
3 changes: 3 additions & 0 deletions quasarpy/algorithm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from quasarpy.algorithm.detector import MainDetector # noqa: F401
from quasarpy.algorithm.llm import LLM # noqa: F401
from quasarpy.algorithm.llm import LLMConfig # noqa: F401
10 changes: 5 additions & 5 deletions quasarx/algorithm/detector.py → quasarpy/algorithm/detector.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from abc import ABC, abstractmethod
import os
from typing import Dict
from quasarx.utils.logger import logger
from quasarpy.utils.logger import logger
import xgboost as xgb
from quasarx.handler.issue import Issue, IssueHandler
from quasarx.utils.redis_server import RedisConfig, RedisServer
from quasarpy.handler.issue import Issue, IssueHandler
from quasarpy.utils.redis_server import RedisConfig, RedisServer
import asyncio
from quasarx.algorithm.llm import LLM
from quasarx.utils import PROMPT_TEMPLATE
from quasarpy.algorithm.llm import LLM
from quasarpy.utils import PROMPT_TEMPLATE



Expand Down
2 changes: 1 addition & 1 deletion quasarx/algorithm/llm.py → quasarpy/algorithm/llm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from transformers import AutoTokenizer, AutoModelForCausalLM
from quasarx.utils.logger import logger
from quasarpy.utils.logger import logger
from dataclasses import dataclass
import huggingface_hub
import os
Expand Down
File renamed without changes.
File renamed without changes.
118 changes: 118 additions & 0 deletions quasarpy/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import click
import os
from datetime import datetime
from quasarpy._version import __version__ as _version
from quasarpy.utils import ASCII_ART
from quasarpy.utils import analyse
from quasarpy.algorithm.detector import MainDetector, detect_smell
from quasarpy.handler.issue import IssueHandler, Repository
from quasarpy.utils.redis_server import generate_report, RedisConfig
import asyncio
from quasarpy.algorithm import LLM, LLMConfig

class ASCIICommandClass(click.Group):
def get_help(self, ctx):
return ASCII_ART + "\n" + super().get_help(ctx)


@click.group(name="cli", cls=ASCIICommandClass)
@click.version_option(_version, prog_name="Quasar")
@click.help_option("-h", "--help")
def cli() -> None:
pass


@cli.command(name="detect", help="Detect code smells")
@click.option(
"--path",
"-p",
type=click.Path(exists=True),
help="Path to the directory to analyse",
)
@click.option(
"--format",
"-f",
type=click.Choice(["json", "pdf", "html"]),
help="Format of the report",
)
@click.option(
"--solution", "-s", is_flag=True, help="Provide solutions for detected code smells"
)
@click.option(
"--create-issue", "-c", is_flag=True, help="Create an issue if a smell is detected"
)
@click.option(
"--output", "-o", type=click.Path(exists=False), help="Output file path for report"
)
@click.option(
"--offline", is_flag=False, help="Use the offline version of the model"
)
def detect(path, format, solution, create_issue, output, offline) -> None:
"""
Detects the specified type of object in the given path and formats the output.
Args:
path (str): The path to the file or directory to be analyzed.
format (str): The desired output format ('json' or 'xml').
solution (bool): Whether to provide solutions for the detected code smells.
create_issue (bool): Whether to create an issue for the detected code smells.
output (str): The path to save the output report.
Raises:
ValueError: If the path is not provided or if format and output path are required but not provided.
NotImplementedError: If the solution flag is set to True (not implemented yet) or if other formats are not implemented yet.
Returns:
None
"""
issue_handler = IssueHandler(repo=Repository()) if create_issue else None
redis_config = RedisConfig()

if solution:
raise NotImplementedError("Solution flag not implemented yet")
else:
try:
if path:
data_json = analyse([path])
if format in ["json", "pdf", "html"]:
try:
llm_config = LLMConfig()
llm = LLM(llm_config, is_online=True if not offline else False)

detector = MainDetector(llm=llm, issue_handler=issue_handler)
data = asyncio.run(detect_smell(data_json, detector))

if not format or not output:
raise ValueError("Format and output path are required")

report_path = os.path.join(
output,
f'report_{datetime.now().strftime("%H%M%S")}',
)

if format == "json":
with open(report_path, "w") as f:
f.write(data)
else:
if not data:
raise ValueError("No data to write")

generate_report(
config=redis_config,
format=format,
data=data,
report_path=report_path,
)

except Exception as e:
raise e
else:
raise NotImplementedError("Other format not implemented yet")
else:
raise ValueError("Path is required")
except Exception as e:
raise e


if __name__ == "__main__":
cli()
1 change: 1 addition & 0 deletions quasarpy/handler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from quasarpy.handler.issue import Issue, IssueHandler, Repository # noqa: F401
2 changes: 1 addition & 1 deletion quasarx/handler/issue.py → quasarpy/handler/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass, field

from quasarx.utils.logger import logger
from quasarpy.utils.logger import logger
from typing import AnyStr, List
import pydantic

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions quasarx/tests/conftest.py → quasarpy/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from quasarx.handler import Repository
from quasarx.handler import Issue
from quasarpy.handler import Repository
from quasarpy.handler import Issue


@pytest.fixture
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from quasarx.handler import Issue, Repository
from quasarpy.handler import Issue, Repository
import pydantic


Expand Down
6 changes: 3 additions & 3 deletions quasarx/tests/test_utils.py → quasarpy/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from quasarx.utils.errors import LiteralEvalError
from quasarx.utils.logger import logger
from quasarx.utils.redis_server import RedisConfig
from quasarpy.utils.errors import LiteralEvalError
from quasarpy.utils.logger import logger
from quasarpy.utils.redis_server import RedisConfig


# Test the logger
Expand Down
8 changes: 8 additions & 0 deletions quasarpy/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from quasarpy.utils.ascii import ASCII_ART # noqa: F401
from quasarpy.utils.analyser import analyse # noqa: F401
from quasarpy.utils.logger import logger # noqa: F401
from quasarpy.utils.errors import LiteralEvalError # noqa: F401
from quasarpy.utils.redis_server import RedisServer # noqa: F401
from quasarpy.utils.redis_server import RedisConfig # noqa: F401
from quasarpy.utils.redis_server import generate_report # noqa: F401
from quasarpy.utils.prompt_template import PROMPT_TEMPLATE # noqa: F401
2 changes: 1 addition & 1 deletion quasarx/utils/analyser.py → quasarpy/utils/analyser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from radon.cli.harvest import RawHarvester
from radon.cli import Config
from radon.metrics import h_visit
from quasarx.utils.errors import LiteralEvalError
from quasarpy.utils.errors import LiteralEvalError
import json


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import redis
import os
from quasarx.utils.logger import logger
from quasarpy.utils.logger import logger
import pydantic
import datetime
from jinja2 import Environment, FileSystemLoader
Expand Down
3 changes: 0 additions & 3 deletions quasarx/algorithm/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion quasarx/handler/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions quasarx/utils/__init__.py

This file was deleted.

0 comments on commit 7b9666a

Please sign in to comment.