Skip to content

Commit cb5a682

Browse files
committed
Merge in main
2 parents 6efbbbc + 110e564 commit cb5a682

232 files changed

Lines changed: 7704 additions & 997 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ env/.env*
1616

1717
# Nginx
1818
logs/nginx/
19+
20+
# Local database
21+
.data/

.gitmodules

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
[submodule "api/ai/group_matcher_algorithm/group-matcher"]
2-
path = api/ai/group_matcher_algorithm/group-matcher
1+
[submodule "simulation_cache"]
2+
path = simulation_cache
3+
url = https://github.com/Teamable-Analytics/algorithms-simulation-cache.git
4+
[submodule "api/ai/external_algorithms/group_matcher_algorithm/group-matcher"]
5+
path = api/ai/external_algorithms/group_matcher_algorithm/group-matcher
36
url = https://github.com/ketphan02/group-matcher.git

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
```
1717
python3 -m pip install -r requirements.txt
1818
```
19-
3. You're good to go!
19+
3. Initialize submodules.
20+
```
21+
git submodule update --init --recursive
22+
```
23+
4. You're good to go!
2024
> Be sure to read any directory-specific README.md and CONVENTION.md files before starting to work.
2125
2226
### Metrics
@@ -50,7 +54,7 @@ python3 -m unittest discover tests
5054
- todo: the logic for each of our algorithms
5155
- todo: the api that serves these algorithms
5256

53-
#### /models
57+
#### /dataclasses
5458

5559
- dataclasses, types, and enums used in the rest of the repository
5660

api/ai/algorithm_runner.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from typing import List, TYPE_CHECKING
22

3+
from api.ai.external_algorithms.group_matcher_algorithm.group_matcher_algorithm import (
4+
GroupMatcherAlgorithm,
5+
)
36
from api.ai.geg_algorithm.geg_algorithm import GeneralizedEnvyGraphAlgorithm
47
from api.ai.interfaces.algorithm_config import (
58
AlgorithmConfig,
@@ -30,10 +33,9 @@
3033
from api.ai.double_round_robin_algorithm.double_round_robin_algorithm import (
3134
DoubleRoundRobinAlgorithm,
3235
)
33-
from api.ai.group_matcher_algorithm.group_matcher_algorithm import GroupMatcherAlgorithm
34-
from api.models.enums import AlgorithmType
35-
from api.models.student import Student
36-
from api.models.team_set import TeamSet
36+
from api.dataclasses.enums import AlgorithmType
37+
from api.dataclasses.student import Student
38+
from api.dataclasses.team_set import TeamSet
3739

3840
if TYPE_CHECKING:
3941
from api.ai.interfaces.algorithm_options import AlgorithmOptions

api/ai/double_round_robin_algorithm/custom_models.py renamed to api/ai/double_round_robin_algorithm/custom_dataclasses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from api.models.student import Student
1+
from api.dataclasses.student import Student
22

33

44
class Utility:

api/ai/double_round_robin_algorithm/double_round_robin_algorithm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
"""
2929
from typing import List, Dict, Set, Callable
3030

31-
from api.ai.double_round_robin_algorithm.custom_models import Utility
31+
from api.ai.double_round_robin_algorithm.custom_dataclasses import Utility
3232
from api.ai.interfaces.algorithm import Algorithm
3333
from api.ai.interfaces.algorithm_config import DoubleRoundRobinAlgorithmConfig
3434
from api.ai.interfaces.algorithm_options import DoubleRoundRobinAlgorithmOptions
3535
from api.ai.interfaces.team_generation_options import TeamGenerationOptions
36-
from api.models.student import Student
37-
from api.models.team import Team, TeamShell
38-
from api.models.team_set import TeamSet
36+
from api.dataclasses.student import Student
37+
from api.dataclasses.team import Team, TeamShell
38+
from api.dataclasses.team_set import TeamSet
3939

4040

4141
class DoubleRoundRobinAlgorithm(Algorithm):

api/ai/external_algorithms/group_matcher_algorithm/__init__.py

Whitespace-only changes.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
from dataclasses import dataclass
2+
from typing import Dict, Iterator
3+
4+
import faker
5+
from pandas import DataFrame
6+
7+
from api.ai.external_algorithms.group_matcher_algorithm.utils import (
8+
fromYearLevelToAlYearLevel,
9+
fromNumbersToTimeSlots,
10+
fromGenderToAlGender,
11+
fromRaceToAlRace,
12+
)
13+
from api.dataclasses.enums import ScenarioAttribute, Gender, Race
14+
from api.dataclasses.student import Student
15+
from api.dataclasses.team import Team
16+
from api.dataclasses.team_set import TeamSet
17+
18+
19+
@dataclass
20+
class GroupMatcherStudent(Student):
21+
def __init__(self, student: Student):
22+
super().__init__(
23+
student.id,
24+
student.name,
25+
student.attributes,
26+
student.relationships,
27+
student.project_preferences,
28+
student.team,
29+
)
30+
self.email = faker.Faker().email()
31+
if not self.name:
32+
self.name = faker.Faker().name()
33+
34+
def get_formatted_data(self):
35+
return {
36+
"Email Address": self.email,
37+
"SID": self.id,
38+
"First name": self.name.split()[0],
39+
"Last name": self.name.split()[1],
40+
"What year are you": fromYearLevelToAlYearLevel(
41+
self.attributes[ScenarioAttribute.YEAR_LEVEL.value][0]
42+
).value,
43+
"Would you like to be part of a course study group?": "Yes",
44+
"Do you have an existing study group of size 2-6 in mind": "No",
45+
"timezone offset": "-7", # all the same timezone
46+
"Would you like to attend the same discussion": "Yes",
47+
"discussion section times": fromNumbersToTimeSlots(
48+
self.attributes.get(
49+
ScenarioAttribute.TIMESLOT_AVAILABILITY.value, ["1"]
50+
)
51+
),
52+
"Will you be on the Berkeley campus": "Yes", # No remote students
53+
"Which of these options best describes your race?": fromRaceToAlRace(
54+
Race(self.attributes.get(ScenarioAttribute.RACE.value, [Race.Other])[0])
55+
).value,
56+
"How do you self-identify?": fromGenderToAlGender(
57+
Gender(self.attributes[ScenarioAttribute.GENDER.value][0])
58+
).value,
59+
}
60+
61+
@staticmethod
62+
def transform_output_data_to_team_set(
63+
output_data: DataFrame,
64+
team_trace: Dict[int, Team],
65+
student_trace: Dict[int, Student],
66+
team_cycler: Iterator[Team],
67+
) -> TeamSet:
68+
for _, row in output_data.iterrows():
69+
student_id = row["sid"]
70+
group_num = int(row["group_num"]) + 1
71+
if group_num not in team_trace.keys():
72+
new_team_attributes = next(team_cycler)
73+
new_team = Team(
74+
_id=len(team_trace) + 1,
75+
name=f"Team {len(team_trace) + 1}",
76+
requirements=new_team_attributes.requirements,
77+
project_id=new_team_attributes.project_id,
78+
students=[],
79+
)
80+
team_trace[int(row["group_num"]) + 1] = new_team
81+
82+
student = student_trace[student_id]
83+
team = team_trace[int(row["group_num"]) + 1]
84+
85+
student.add_team(team)
86+
team.add_student(student)
87+
88+
return TeamSet(
89+
teams=[team for team in team_trace.values() if len(team.students) > 0]
90+
)
Submodule group-matcher added at dc00ecc

0 commit comments

Comments
 (0)