Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspections analysis #26

Merged
merged 42 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e5ef9a2
fix: use the `list2cmdline` function for command representation
GirZ0n Oct 16, 2023
c3010d9
feat: add the `ij_config` and `new_format` fields
GirZ0n Oct 16, 2023
6110a30
deps: add streamlit-diff-viewer
GirZ0n Oct 16, 2023
30aa8f6
feat: add the `INSPECTIONS` field
GirZ0n Oct 16, 2023
3b23fc9
feat: add the script for gathering inspections
GirZ0n Oct 16, 2023
54002e6
fix: add 'ij' and 'dataframe' to whitelist
GirZ0n Oct 16, 2023
820e3db
style: fix flake8's issues
GirZ0n Oct 16, 2023
df17cfa
Sort whitelist (GitHub Actions)
GirZ0n Oct 16, 2023
0639da2
fix: add WPS359 to whitelist
GirZ0n Oct 16, 2023
c075fa1
Merge remote-tracking branch 'origin/inspections-analysis' into inspe…
GirZ0n Oct 16, 2023
eafcb8e
Sort whitelist (GitHub Actions)
GirZ0n Oct 16, 2023
5c9b9a6
feat: add inspections analysis
GirZ0n Oct 17, 2023
80e9812
fix: add WPS359 to ignore
GirZ0n Oct 17, 2023
526cdc5
fix: add new words to whitelist
GirZ0n Oct 17, 2023
f3fd0f0
deps: add plotly
GirZ0n Oct 17, 2023
1f4dfc0
fix: update the inspections column format
GirZ0n Oct 17, 2023
36f288b
todo: added new todo
GirZ0n Oct 17, 2023
9ec0934
Merge remote-tracking branch 'origin/inspections-analysis' into inspe…
GirZ0n Oct 17, 2023
47d55b8
Sort whitelist (GitHub Actions)
GirZ0n Oct 17, 2023
fb974b0
fix: fix small bug
GirZ0n Oct 17, 2023
14891f2
Merge remote-tracking branch 'origin/inspections-analysis' into inspe…
GirZ0n Oct 17, 2023
e78c7da
fix: make visualization look better
GirZ0n Oct 18, 2023
2bc5f8b
style: fix flake8's issues
GirZ0n Oct 18, 2023
7f58998
style: fix flake8's issues
GirZ0n Oct 18, 2023
6662713
style: make the code look better
GirZ0n Oct 18, 2023
c1ea2ae
fix: fix a small bug
GirZ0n Oct 18, 2023
e1accb7
feat: add the ability to choose those inspections to ignore
GirZ0n Oct 23, 2023
1cbb623
feat: added a script entry for inspections gathering
GirZ0n Oct 23, 2023
3e21d26
feat: add `expander` to the whitelist
GirZ0n Oct 23, 2023
0535037
Sort whitelist (GitHub Actions)
GirZ0n Oct 23, 2023
7f0bec1
bump: bump the version to 0.3.0
GirZ0n Oct 23, 2023
722b3da
fix: update the README file
GirZ0n Oct 23, 2023
ffa7c70
Merge remote-tracking branch 'origin/inspections-analysis' into inspe…
GirZ0n Oct 23, 2023
01b29c3
feat: add `postfix` to the whitelist
GirZ0n Oct 24, 2023
04978cd
refactor: change JBA tests structure
GirZ0n Oct 24, 2023
078901b
feat: add more tests for `prepare_course_data`
GirZ0n Oct 24, 2023
ce4541b
refactor: rewrite structure extraction to be able to work with any co…
GirZ0n Oct 24, 2023
b7eb086
Sort whitelist (GitHub Actions)
GirZ0n Oct 24, 2023
9c1648b
fix: fix typos
GirZ0n Oct 24, 2023
f171adf
Merge remote-tracking branch 'origin/structure-script-refactoring' in…
GirZ0n Oct 24, 2023
6fb2caf
feat: add the `read_yaml_field_content` function
GirZ0n Oct 24, 2023
a01289f
Merge pull request #27 from hyperskill/structure-script-refactoring
nbirillo Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ ignore =
WPS347,
# Forbid starting lines with a dot
WPS348,
# Forbids to unpack iterable objects to lists. Disabled due to false-positives with pandas
WPS359,
# Forbid mutable constants on a module level
WPS407,
# Forbid logic inside __init__ module
Expand All @@ -65,6 +67,8 @@ ignore =
WPS432,
# Forbid overlapping local and block variables. Disabled due to false-positives
WPS440,
# Forbids direct usage of multiline strings
WPS462,
# Forbid comparisons between bitwise and boolean expressions
WPS465,
# Forbid @staticmethod decorator
Expand Down
11 changes: 11 additions & 0 deletions core/src/utils/file/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
def parse_yaml(path: Union[Path, str]) -> Any:
with open(path) as file:
return yaml.safe_load(file)


def read_yaml_field_content(yaml_file: Path, field_name: str) -> Any:
if not yaml_file.exists():
raise ValueError(f'{field_name} does not exist.')

parsed_yaml_file = parse_yaml(yaml_file)
if parsed_yaml_file is None:
raise ValueError(f'`{yaml_file} is empty.')

return parsed_yaml_file.get(field_name)
1 change: 1 addition & 0 deletions data_labelling/src/hyperstyle/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def main():
config = HyperstyleEvaluationConfig(tool_path=args.tool_path,
allow_duplicates=args.allow_duplicates,
with_all_categories=args.with_all_categories,
new_format=False,
tmp_path=args.tmp_directory,
disable=args.disable,
working_directory=args.working_directory,
Expand Down
34 changes: 23 additions & 11 deletions data_labelling/src/hyperstyle/hyperstyle_evaluation_config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
import logging.config
import platform
import sys
from pathlib import Path
from typing import List, Optional, Union
from typing import List, Optional, Union, Dict

from hyperstyle.src.python.review.application_config import LanguageVersion

Expand All @@ -12,17 +13,23 @@

HYPERSTYLE_TOOL_PATH = 'review/hyperstyle/src/python/review/run_tool.py'

IJConfig = Dict[str, Dict[str, str]]


class HyperstyleEvaluationConfig(EvaluationConfig):
def __init__(self,
tool_path: str,
allow_duplicates: bool,
with_all_categories: bool,
tmp_path: Path,
n_cpu: Optional[int] = None,
disable: Optional[str] = None,
working_directory: Optional[str] = None,
venv: Optional[str] = None):
def __init__(
self,
tool_path: str,
allow_duplicates: bool,
with_all_categories: bool,
new_format: bool,
tmp_path: Path,
n_cpu: Optional[int] = None,
disable: Optional[str] = None,
working_directory: Optional[str] = None,
venv: Optional[str | Path] = None,
ij_config: Optional[IJConfig] = None,
):
"""
`tool_path` - path to hyperstyle tool running script (custom or HYPERSTYLE_TOOL_PATH)
`tmp_path` - path where to place evaluation temporary files
Expand All @@ -37,10 +44,12 @@ def __init__(self,

self.allow_duplicates: bool = allow_duplicates
self.with_all_categories: bool = with_all_categories
self.new_format: bool = new_format
self.n_cpu: int = n_cpu
self.disable: Optional[str] = disable
self.ij_config: Optional[IJConfig] = ij_config
self.working_directory: Optional[str] = working_directory
self.venv: Optional[str] = venv
self.venv: Optional[str | Path] = venv

def build_command(self,
input_path: Union[str, Path],
Expand Down Expand Up @@ -73,6 +82,9 @@ def build_command(self,
if self.disable:
python_command += ['--disable', self.disable]

if self.ij_config:
python_command += ['--ij-config', json.dumps(self.ij_config)]

if platform.system() == 'Darwin':
bash_prefix = None
else:
Expand Down
5 changes: 3 additions & 2 deletions data_labelling/src/utils/evaluation_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
import subprocess
import time
from pathlib import Path
from typing import Callable, List, TypeVar, Optional, Tuple

import pandas as pd
import time

from core.src.model.column_name import SubmissionColumns
from core.src.utils.file.file_utils import create_directory, remove_directory, create_file
Expand Down Expand Up @@ -70,7 +71,7 @@ def evaluate_command(command: List[str], working_directory: Optional[str] = None
logger.info('Start evaluation')
start = time.time()

logger.info(f'Executing command: {" ".join(command)}')
logger.info(f'Executing command: {subprocess.list2cmdline(command)}')
output, _ = run_in_subprocess(command, working_directory=working_directory)

end = time.time()
Expand Down
Loading
Loading