Skip to content

Commit

Permalink
Merge pull request #49 from chriswebb09/dev-branch
Browse files Browse the repository at this point in the history
Dev branch
  • Loading branch information
chriswebb09 authored Dec 15, 2023
2 parents b0d4600 + 7d10ffc commit 7d7a043
Show file tree
Hide file tree
Showing 21 changed files with 471 additions and 399 deletions.
33 changes: 16 additions & 17 deletions DirectReport/browserview/app.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
#!/usr/bin/env python3

import sys
from pathlib import Path

from flask import Flask, render_template, request, redirect, json, url_for
from werkzeug.security import generate_password_hash
from DirectReport.models.user_model import UserModel
from DirectReport.models.list_builder import ListBuilder
from DirectReport.models.report_model import ReportModel
from DirectReport.models.report_builder import ReportBuilder
from DirectReport.models.report import Report
from DirectReport.browserview.prompt_logic import generate_email
from flask_login import LoginManager, login_required, current_user

from DirectReport.browserview.github import GithubClient
from DirectReport.browserview.github import GoogleAIClient
from DirectReport.browserview.github import HuggingFaceClient
from flask_login import LoginManager, login_user, login_required, logout_user, current_user
from DirectReport.browserview.prompt_logic import generate_email
from DirectReport.datadependencies import appsecrets
from DirectReport.models.user_model import UserModel
from .auth.auth import auth
from .reportbp import reportsbp
from .modelclient import TEST_DATA_ELEMENTS
from .modelclient import RAW_REPORT_DATA
from .modelclient import RAW_REPORT_DATA_2

import sys
from pathlib import Path

file = Path(__file__).resolve()
package_root_directory = file.parents[1]
Expand Down Expand Up @@ -85,7 +76,7 @@ def unauthorized_handler():

@app.route("/team", methods=['GET'])
def team():
return render_template('team.html', title='Team', data=[])
return render_template('team/team.html', title='Team', data=[])

@app.route("/generate_email", methods=['POST'])
def generate_email():
Expand All @@ -96,5 +87,13 @@ def generate_email():
elements = {"email": report.choices[0].message.content}
return elements, 201

@app.route("/repo/<reponame>", methods=['GET'])
def repo(reponame=None):

client = GithubClient()
repo = client.get_repo_issues("chriswebb09", reponame)
print(repo)
return render_template('team/team.html', title='Team', data=[])

if __name__ == "__main__":
app.run(debug=True, port=5000)
5 changes: 3 additions & 2 deletions DirectReport/browserview/github.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python3

import json
import re

import requests
import json

from DirectReport.datadependencies import appsecrets, prompts


Expand Down Expand Up @@ -91,7 +93,6 @@ class GoogleAIClient:


def query(self, prompt):
print(prompts.GENERATE_SUMMARY_PROMPT_PREIX)
API_URL = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={appsecrets.GOOGLE_AI_TOKEN}"
headers = {"Content-Type": "application/json"}
prompt_data = prompts.GENERATE_SUMMARY_PROMPT_PREIX + prompt
Expand Down
1 change: 1 addition & 0 deletions DirectReport/browserview/prompt_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import openai

from DirectReport.datadependencies import appsecrets, prompts

openai.api_key = appsecrets.SECRET_KEY
Expand Down
94 changes: 26 additions & 68 deletions DirectReport/browserview/reportbp.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env python3

import ast
from flask import Flask, render_template, request, json
from flask import Blueprint
from DirectReport.browserview.app import login_required
from flask import render_template, request, json
from flask_login import login_required, current_user
from .modelclient import RAW_REPORT_DATA
from .modelclient import RAW_REPORT_DATA_2
from DirectReport.models.report_builder import ReportBuilder

from DirectReport.browserview.github import GithubClient
from DirectReport.browserview.github import GoogleAIClient
from DirectReport.models.entry_storage import EntryStorage
from DirectReport.models.list_builder import ListBuilder
from DirectReport.models.report_builder import ReportBuilder
from DirectReport.models.report_model import ReportModel

reportsbp = Blueprint('reportsbp', __name__)

Expand All @@ -18,38 +18,31 @@
def report():
prompt = ""
prompt = request.get_json()["prompt"]
elements = RAW_REPORT_DATA_2
client = GithubClient()
user_repos = client.get_user_repos("chriswebb09")
repodata = []
for repo in user_repos:
print(repo)
# print(repo["name"])
# print(repo["full_name"])
# print(repo["html_url"])
# print(repo["language"])
# print(repo["description"])
# print(repo["stargazers_count"])
# print(repo["watchers_count"])
# print("\n")
logitem = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement"
print("\n")
repodata.append(repo["name"])
log_item = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement"
googleAi = GoogleAIClient()
response_data = googleAi.get_data_from(prompt).replace("\'", "\"")
response_data = response_data.replace("\n", " ")
data_json = json.loads(response_data)
data_json["broad_categories"] = {"debug_info": 16, "code_maintenance": 9, "documentation": 7, "test_related": 6, "nonbreaking_space_handling": 5, "readme_update": 1, "syntax_fix": 1}
data_json["shortlog"] = client.parse_git_shortlog(logitem)
data_json["shortlog"] = client.parse_git_shortlog(log_item)
data_json["repos"] = repodata
ReportBuilder.new(data_json, prompt, current_user.id)
return data_json, 201

@reportsbp.route("/teamreport", methods=['GET', 'POST'])
@login_required
def team_report():
if request.method == "POST":
print("POST")
# json_data = request.get_json()
# report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at'])
# print("POST")
return render_template('teamreport.html', title='Team Report', data=[])
json_data = request.get_json()
report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at'])
return render_template('team/teamreport.html', title='Team Report', data=[])

@reportsbp.route('/entry/<uid>', methods=['GET', 'POST'])
@login_required
Expand All @@ -60,58 +53,24 @@ def detail(uid=None):
:param uid: The ID of the entry to display.
:return: Rendered HTML template for the entry details page.
"""
# print(uid)
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
# report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
# print(report)
reportJSON = {'report': {
'broad_categories': {'code_maintenance': 9, 'debug_info': 16, 'documentation': 7, 'nonbreaking_space_handling': 5, 'readme_update': 1, 'syntax_fix': 1, 'test_related': 6},
'report': {
'areas_of_focus': ['DebugInfo and SILGen Enhancements', 'Parser Improvements', 'Various Fixes'],
'conclusion': 'The team demonstrated good progress this week, with a focus on enhancing DebugInfo and SILGen, improving the Parser, and implementing various fixes. The team should continue to focus on these areas in the coming week.',
'highlights': [
{'description': 'Adrian Prantl made significant contributions to the DebugInfo and SILGen, including adding support for debuginfo for coroutine allocas, inlined and specialized generic variables.', 'title': 'DebugInfo and SILGen Enhancements'},
{'description': 'Ahmad Alhashemi worked on the Parser, detecting non-breaking space U+00A0 and providing a fix.', 'title': 'Parser Improvements'},
{'description': 'The team worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.', 'title': 'Various Fixes'}
],
'summary': 'The team made significant progress this week with a total of 83 commits. The main focus was on DebugInfo and SILGen enhancements, Parser improvements, and various fixes.',
'total_commits': '83'
},
'shortlog': {'Adrian Prantl': 67, 'Ahmad Alhashemi': 5, 'Akshay Shrimali': 1, 'Alan Zeino': 1, 'Albin Sadowski': 1, 'Alejandro': 3, 'Alex Blewitt': 5},
'team': [
{'accomplishments': 'Adrian made significant contributions to the DebugInfo and SILGen, including adding support for debug info for coroutine allocas, inlined and specialized generic variables. He also worked on the mangling testcase, fixed source locations of variable assignments and function calls, and added build-script support for Swift LLDB backwards-compatibility tests.', 'commits': '67', 'name': 'Adrian Prantl'},
{'accomplishments': 'Alan fixed a typo in the code example in libSyntax README.', 'commits': '1', 'name': 'Alan Zeino'},
{'accomplishments': 'Alejandro removed a warning, made some documentation fixes, fixed Binary Floating Point. random(in:) open range returning upperBound, and fixed a minor code typo in SILPro.', 'commits': '3', 'name': 'Alejandro'},
{'accomplishments': 'Akshay updated the README.md file.', 'commits': '1', 'name': 'Akshay Shrimali'},
{'accomplishments': 'Ahmad worked on the Parser, detecting non-breaking space U+00A0 and providing a fix. He also made minor style edits and added more non-breaking space testcases.', 'commits': '5', 'name': 'Ahmad Alhashemi'},
{'accomplishments': 'Albin fixed syntax highlighting in CHANGELOG.', 'commits': '1', 'name': 'Albin Sadowski'},
{'accomplishments': 'Alex worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.', 'commits': '5', 'name': 'Alex Blewitt'}
]
},
'created_at': '1702314769.558132'}

# json.loads(json.dumps(report))
# report = {}
# item = EntryStorage('SQLite_Python.db')
# if request.method == "POST":
# json_data = request.get_json()
# ListBuilder.update(
# json_data["id"], json_data['entry'], json_data['topic'], json_data['created_at'], json_data['week_id']
# )
# entry = item.get_entry(uid).to_dict()
report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
json.loads(json.dumps(report))
item = EntryStorage('SQLite_Python.db')
if request.method == "POST":
json_data = request.get_json()
ListBuilder.update(
json_data["id"], json_data['entry'], json_data['topic'], json_data['created_at'], json_data['week_id']
)
entry = item.get_entry(uid).to_dict()
return render_template('detail.html', title='Detail', data=reportJSON)

@reportsbp.route("/getreport/<uid>", methods=['GET'])
@login_required
def get_report(uid=None):
print(uid)
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
# report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
# hugClient = HuggingFaceClient()
# result = hugClient.query({
# "inputs": "Can you please let us know more details about your ",
# })
return RAW_REPORT_DATA_2, 201
report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
return report, 201

@reportsbp.route("/getlist", methods=['GET'])
@login_required
Expand All @@ -127,7 +86,6 @@ def list_entries():
:return: Rendered HTML template for the list page.
"""
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
print(reports)
report_results = []
for report in reports:
report_element = {
Expand Down
3 changes: 3 additions & 0 deletions DirectReport/browserview/static/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dropdown:hover .dropdown-menu {
display: block;
}
Loading

0 comments on commit 7d7a043

Please sign in to comment.