Skip to content

Commit

Permalink
Correction to autograder.py to better accomodate notebook_stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Gchism94 committed Feb 29, 2024
1 parent 6574b25 commit 116f9de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
28 changes: 18 additions & 10 deletions jupyterquest/autograder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ def main():
repo_path = os.getenv('GITHUB_WORKSPACE', '.')

# 1. Check Repository Structure
required_directories = ['data', 'images'] # Assuming these directories are required
allowed_files_patterns = ['README.md', '.gitignore', 'LICENSE', 'requirements.txt', '*.ipynb'] # Updated patterns
required_directories = ['data', 'images']
allowed_files_patterns = ['README.md', '.gitignore', 'LICENSE', 'requirements.txt', '*.ipynb']
repo_structure_results = check_directory_structure(
repo_path, required_directories, allowed_files_patterns
)
print("Repository Structure Check Results:", repo_structure_results)

# 2. Code Quality and Style Checks
# Assuming you have a way to get code_blocks (list of strings) from .ipynb files
first_ipynb_path = find_first_ipynb_file(repo_path)
code_blocks = parse_ipynb(first_ipynb_path)['code_cells'] if first_ipynb_path else []
if first_ipynb_path:
parsed_notebook = parse_ipynb(first_ipynb_path)
code_blocks = parsed_notebook['code_cells']
markdown_cells = parsed_notebook['markdown_cells']
else:
code_blocks = []
markdown_cells = []

code_quality_results = assess_code_quality(code_blocks)
code_style_results = check_code_style(code_blocks)
print("Code Quality Results:", code_quality_results)
Expand All @@ -36,22 +42,24 @@ def main():
commit_analysis_results = analyze_commit_messages(repo_path)
print("Commit Analysis Results:", commit_analysis_results)

# 4. Parse .ipynb File (if needed separately)
# If additional information from the .ipynb file is needed, parse as required

# Compile all results into a final Markdown report
notebook_stats = {
'total_code_cells': len(code_blocks),
'total_markdown_cells': len(markdown_cells)
}

final_report = generate_markdown_report(
code_quality_results,
repo_structure_results,
{
"Code Style Results": code_style_results,
"Commit Analysis Results": commit_analysis_results,
# "Parsed .ipynb Content": parsed_content # Include this if there's specific content to report
}
},
notebook_stats=notebook_stats
)

# Save the report as a .md file
report_file_path = os.path.join(repo_path, 'autograder_report.md') # Ensure it saves in the correct directory
report_file_path = os.path.join(repo_path, 'autograder_report.md')
save_markdown_report(final_report, report_file_path)

if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions jupyterquest/generate_markdown_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def generate_markdown_report(quality_reports, repo_structure_results, notebook_s
"""Generates a comprehensive Markdown (.md) report from various checks."""
report_md = "# Introduction\n\nThis report presents the results of the autograding process for a Jupyter notebook...\n\n"

# Add Notebook Statistics (if applicable)
if notebook_stats:
report_md += "## Notebook Statistics\n"
# Include notebook stats if provided
if notebook_stats and 'total_code_cells' in notebook_stats:
report_md += f"- **Total Code Cells**: {notebook_stats['total_code_cells']}\n"
report_md += f"- **Total Markdown Cells**: {notebook_stats['total_markdown_cells']}\n\n"
else:
report_md += "- **Total Code Cells**: Data not available\n"

# Add Repository Structure Check Results
report_md += "## Repository Structure Check\n"
Expand Down

0 comments on commit 116f9de

Please sign in to comment.