Skip to content

Commit e35ebdc

Browse files
authored
[PERF-321] Import deadlock fix (#99)
* Moved student assessment tests to remove cycle and additional dependency fixes * comment cleanup
1 parent c0ebd2f commit e35ebdc

File tree

22 files changed

+264
-148
lines changed

22 files changed

+264
-148
lines changed

src/edfi-performance-test/edfi_performance_test/api/client/academic_week.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44
# See the LICENSE and NOTICES files in the project root for more information.
55

66
from edfi_performance_test.api.client.ed_fi_api_client import EdFiAPIClient
7+
from edfi_performance_test.api.client.school import SchoolClient
78

89

910
class AcademicWeekClient(EdFiAPIClient):
1011
endpoint = "academicWeeks"
12+
13+
def create_with_dependencies(self, **kwargs):
14+
# Pre-populate school
15+
school_id = kwargs.pop("schoolId", SchoolClient.shared_elementary_school_id())
16+
17+
# Create academicWeek
18+
return self.create_using_dependencies(
19+
schoolReference__schoolId=school_id,
20+
**kwargs
21+
)

src/edfi-performance-test/edfi_performance_test/api/client/assessment.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,3 @@ def create_with_dependencies(self, **kwargs):
5555
]["assessmentIdentifier"],
5656
**kwargs
5757
)
58-
59-
60-
class StudentAssessmentClient(EdFiAPIClient):
61-
endpoint = "studentAssessments"
62-
63-
dependencies: Dict = {AssessmentClient: {}}
64-
65-
def create_with_dependencies(self, **kwargs):
66-
# Create new assessment
67-
assessment_reference = self.assessment_client.create_with_dependencies()
68-
69-
# Create student assessment
70-
return self.create_using_dependencies(
71-
assessment_reference,
72-
assessmentReference__assessmentIdentifier=assessment_reference[
73-
"attributes"
74-
]["assessmentIdentifier"],
75-
**kwargs
76-
)

src/edfi-performance-test/edfi_performance_test/api/client/post_secondary.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,13 @@
33
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
44
# See the LICENSE and NOTICES files in the project root for more information.
55

6-
7-
import threading
86
from edfi_performance_test.api.client.ed_fi_api_client import EdFiAPIClient
7+
from edfi_performance_test.api.client.student import StudentClient
98

109

1110
class PostSecondaryInstitutionClient(EdFiAPIClient):
1211
endpoint = "postSecondaryInstitutions"
1312

14-
_post_secondary_institute_id = None
15-
_lock = threading.Lock()
16-
17-
@classmethod
18-
def shared_post_secondary_institute_id(cls):
19-
if cls._post_secondary_institute_id is not None:
20-
return cls._post_secondary_institute_id
21-
else:
22-
with cls._lock:
23-
if cls._post_secondary_institute_id is not None:
24-
return cls._post_secondary_institute_id
25-
cls._post_secondary_institute_id = cls.create_shared_resource("postSecondaryInstitutionId")
26-
return cls._post_secondary_institute_id
27-
2813

2914
class PostSecondaryEventClient(EdFiAPIClient):
3015
endpoint = "postSecondaryEvents"
@@ -34,6 +19,9 @@ class PostSecondaryEventClient(EdFiAPIClient):
3419
}
3520

3621
def create_with_dependencies(self, **kwargs):
22+
# Prepopulated student
23+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
24+
3725
# Create new student for association
3826
institution_reference = self.institution_client.create_with_dependencies()
3927

@@ -44,5 +32,6 @@ def create_with_dependencies(self, **kwargs):
4432
][
4533
"postSecondaryInstitutionId"
4634
],
35+
studentReference__studentUniqueId=studentUniqueId,
4736
**kwargs
4837
)

src/edfi-performance-test/edfi_performance_test/api/client/report_card.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Dict
77
from edfi_performance_test.api.client.ed_fi_api_client import EdFiAPIClient
88
from edfi_performance_test.api.client.grading_period import GradingPeriodClient
9+
from edfi_performance_test.api.client.student import StudentClient
910

1011

1112
class ReportCardClient(EdFiAPIClient):
@@ -16,11 +17,14 @@ class ReportCardClient(EdFiAPIClient):
1617
}
1718

1819
def create_with_dependencies(self, **kwargs):
20+
# Prepopulated student
21+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
1922
period_reference = self.grading_period_client.create_with_dependencies()
2023

2124
return self.create_using_dependencies(
2225
period_reference,
2326
gradingPeriodReference__periodSequence=period_reference["attributes"][
2427
"periodSequence"
2528
],
29+
studentReference__studentUniqueId=studentUniqueId,
2630
)

src/edfi-performance-test/edfi_performance_test/api/client/restraint.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44
# See the LICENSE and NOTICES files in the project root for more information.
55

66
from edfi_performance_test.api.client.ed_fi_api_client import EdFiAPIClient
7+
from edfi_performance_test.api.client.student import StudentClient
78

89

910
class RestraintEventClient(EdFiAPIClient):
1011
endpoint = "restraintEvents"
12+
13+
def create_with_dependencies(self, **kwargs):
14+
# Prepopulated student
15+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
16+
17+
# Create restraint event
18+
return self.create_using_dependencies(
19+
studentReference__studentUniqueId=studentUniqueId,
20+
**kwargs
21+
)

src/edfi-performance-test/edfi_performance_test/api/client/student.py

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-License-Identifier: Apache-2.0
1+
# SPDX-License-Identifier: Apache-2.0
22
# Licensed to the Ed-Fi Alliance under one or more agreements.
33
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
44
# See the LICENSE and NOTICES files in the project root for more information.
@@ -7,6 +7,7 @@
77

88
from edfi_performance_test.api.client.ed_fi_api_client import EdFiAPIClient
99
from edfi_performance_test.api.client.assessment import LearningObjectiveClient
10+
from edfi_performance_test.api.client.assessment import AssessmentClient
1011
from edfi_performance_test.api.client.competency_objective import (
1112
CompetencyObjectiveClient,
1213
)
@@ -453,6 +454,9 @@ class StudentCompetencyObjectiveClient(EdFiAPIClient):
453454
}
454455

455456
def create_with_dependencies(self, **kwargs):
457+
# Prepopulated student
458+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
459+
456460
# Create grading period
457461
period_reference = self.grading_period_client.create_with_dependencies()
458462

@@ -473,16 +477,36 @@ def create_with_dependencies(self, **kwargs):
473477
objectiveCompetencyObjectiveReference__objective=objective_reference[
474478
"attributes"
475479
]["objective"],
480+
studentReference__studentUniqueId=studentUniqueId,
476481
)
477482

478483

479484
class StudentCTEProgramAssociationClient(EdFiAPIClient):
480485
endpoint = "studentCTEProgramAssociations"
481486

487+
def create_with_dependencies(self, **kwargs):
488+
# Prepopulated student
489+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
490+
491+
return self.create_using_dependencies(
492+
studentReference__studentUniqueId=studentUniqueId,
493+
**kwargs
494+
)
495+
482496

483497
class StudentEducationOrganizationResponsibilityAssociationClient(EdFiAPIClient):
484498
endpoint = "studentEducationOrganizationResponsibilityAssociations"
485499

500+
def create_with_dependencies(self, **kwargs):
501+
# Prepopulated student
502+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
503+
504+
# Create student academic record
505+
return self.create_using_dependencies(
506+
studentReference__studentUniqueId=studentUniqueId,
507+
**kwargs
508+
)
509+
486510

487511
class StudentGradebookEntryClient(EdFiAPIClient):
488512
endpoint = "studentGradebookEntries"
@@ -551,6 +575,16 @@ def delete_with_dependencies(self, reference, **kwargs):
551575
class StudentHomelessProgramAssociationClient(EdFiAPIClient):
552576
endpoint = "studentHomelessProgramAssociations"
553577

578+
def create_with_dependencies(self, **kwargs):
579+
# Prepopulated student
580+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
581+
582+
# Create student academic record
583+
return self.create_using_dependencies(
584+
studentReference__studentUniqueId=studentUniqueId,
585+
**kwargs
586+
)
587+
554588

555589
class StudentInterventionAssociationClient(EdFiAPIClient):
556590
endpoint = "studentInterventionAssociations"
@@ -560,6 +594,9 @@ class StudentInterventionAssociationClient(EdFiAPIClient):
560594
}
561595

562596
def create_with_dependencies(self, **kwargs):
597+
# Prepopulated student
598+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
599+
563600
intervention_reference = self.intervention_client.create_with_dependencies()
564601

565602
return self.create_using_dependencies(
@@ -569,6 +606,7 @@ def create_with_dependencies(self, **kwargs):
569606
][
570607
"interventionIdentificationCode"
571608
],
609+
studentReference__studentUniqueId=studentUniqueId,
572610
**kwargs
573611
)
574612

@@ -581,6 +619,9 @@ class StudentInterventionAttendanceEventClient(EdFiAPIClient):
581619
}
582620

583621
def create_with_dependencies(self, **kwargs):
622+
# Prepopulated student
623+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
624+
584625
intervention_reference = self.intervention_client.create_with_dependencies()
585626

586627
return self.create_using_dependencies(
@@ -590,13 +631,24 @@ def create_with_dependencies(self, **kwargs):
590631
][
591632
"interventionIdentificationCode"
592633
],
634+
studentReference__studentUniqueId=studentUniqueId,
593635
**kwargs
594636
)
595637

596638

597639
class StudentLanguageInstructionProgramAssociationClient(EdFiAPIClient):
598640
endpoint = "studentLanguageInstructionProgramAssociations"
599641

642+
def create_with_dependencies(self, **kwargs):
643+
# Prepopulated student
644+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
645+
646+
# Create student academic record
647+
return self.create_using_dependencies(
648+
studentReference__studentUniqueId=studentUniqueId,
649+
**kwargs
650+
)
651+
600652

601653
class StudentLearningObjectiveClient(EdFiAPIClient):
602654
endpoint = "studentLearningObjectives"
@@ -607,6 +659,9 @@ class StudentLearningObjectiveClient(EdFiAPIClient):
607659
}
608660

609661
def create_with_dependencies(self, **kwargs):
662+
# Prepopulated student
663+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
664+
610665
objective_reference = self.objective_client.create_with_dependencies()
611666

612667
period_reference = self.grading_period_client.create_with_dependencies()
@@ -622,21 +677,85 @@ def create_with_dependencies(self, **kwargs):
622677
gradingPeriodReference__periodSequence=period_reference["attributes"][
623678
"periodSequence"
624679
],
680+
studentReference__studentUniqueId=studentUniqueId,
625681
**kwargs
626682
)
627683

628684

629685
class StudentMigrantEducationProgramAssociationClient(EdFiAPIClient):
630686
endpoint = "studentMigrantEducationProgramAssociations"
631687

688+
def create_with_dependencies(self, **kwargs):
689+
# Prepopulated student
690+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
691+
692+
# Create student academic record
693+
return self.create_using_dependencies(
694+
studentReference__studentUniqueId=studentUniqueId,
695+
**kwargs
696+
)
697+
632698

633699
class StudentNeglectedOrDelinquentProgramAssociationClient(EdFiAPIClient):
634700
endpoint = "studentNeglectedOrDelinquentProgramAssociations"
635701

702+
def create_with_dependencies(self, **kwargs):
703+
# Prepopulated student
704+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
705+
706+
# Create student academic record
707+
return self.create_using_dependencies(
708+
studentReference__studentUniqueId=studentUniqueId,
709+
**kwargs
710+
)
711+
636712

637713
class StudentProgramAttendanceEventClient(EdFiAPIClient):
638714
endpoint = "studentProgramAttendanceEvents"
639715

716+
def create_with_dependencies(self, **kwargs):
717+
# Prepopulated student
718+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
719+
720+
# Create student academic record
721+
return self.create_using_dependencies(
722+
studentReference__studentUniqueId=studentUniqueId,
723+
**kwargs
724+
)
725+
640726

641727
class StudentSchoolFoodServiceProgramAssociationClient(EdFiAPIClient):
642728
endpoint = "studentSchoolFoodServiceProgramAssociations"
729+
730+
def create_with_dependencies(self, **kwargs):
731+
# Prepopulated student
732+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
733+
734+
# Create student academic record
735+
return self.create_using_dependencies(
736+
studentReference__studentUniqueId=studentUniqueId,
737+
**kwargs
738+
)
739+
740+
741+
class StudentAssessmentClient(EdFiAPIClient):
742+
endpoint = "studentAssessments"
743+
744+
dependencies: Dict = {AssessmentClient: {}}
745+
746+
def create_with_dependencies(self, **kwargs):
747+
# Prepopulated student
748+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
749+
750+
# Create new assessment
751+
assessment_reference = self.assessment_client.create_with_dependencies()
752+
753+
# Create student assessment
754+
return self.create_using_dependencies(
755+
assessment_reference,
756+
assessmentReference__assessmentIdentifier=assessment_reference[
757+
"attributes"
758+
]["assessmentIdentifier"],
759+
studentReference__studentUniqueId=studentUniqueId,
760+
**kwargs
761+
)

src/edfi-performance-test/edfi_performance_test/api/client/v4/assessment.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from edfi_performance_test.api.client.ed_fi_api_client import EdFiAPIClient
99
from edfi_performance_test.api.client.school import SchoolClient
10+
from edfi_performance_test.api.client.student import StudentClient
1011

1112

1213
class StudentAssessmentEducationOrganizationAssociationClient(EdFiAPIClient):
@@ -19,6 +20,8 @@ class StudentAssessmentEducationOrganizationAssociationClient(EdFiAPIClient):
1920
}
2021

2122
def create_with_dependencies(self, **kwargs):
23+
# Prepopulated student
24+
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
2225

2326
assessment_reference = self.assessment_client.create_with_dependencies()
2427

@@ -34,8 +37,6 @@ def create_with_dependencies(self, **kwargs):
3437
studentAssessmentReference__studentAssessmentIdentifier=assessment_reference[
3538
"attributes"
3639
]["studentAssessmentIdentifier"],
37-
studentAssessmentReference__studentUniqueId=assessment_reference[
38-
"attributes"
39-
]["studentReference"]["studentUniqueId"],
40+
studentAssessmentReference__studentUniqueId=studentUniqueId,
4041
**kwargs
4142
)

0 commit comments

Comments
 (0)