Problem
A CSV file contains users from multiple UCS@school schools. The school is provided per user, for example through the column school_number.
With Single Source Partial Import (SiSoPi) enabled, the import fails without a fixed school:
No 'school' was specified in the configuration.
Specifying a school with -s, for example -s e915, allows the configuration check to pass, but users from other schools are rejected:
In the SingleSourcePartialImport scenario it is not allowed to
import into any other school that the one configured ('e915').
Investigation
Check the effective import configuration in the import log.
If it contains:
'classes': {
'user_importer': 'ucsschool.importer.mass_import.sisopi_user_import.SingleSourcePartialUserImport'
},
'configuration_checks': ['sisopi']
the import is running in SiSoPi mode.
The CSV mapping may already correctly provide the school:
"school_number": "school"
However, SiSoPi still requires the complete import run to be restricted to one configured school.
Root Cause
SiSoPi is intended for an import scoped to one school. It therefore cannot process a single CSV file containing users whose primary schools differ from row to row.
For such a CSV, the normal UCS@school UserImport must be used instead.
Solution
Configure the dedicated import to use the normal user importer:
"classes": {
"user_importer": "ucsschool.importer.mass_import.user_import.UserImport"
},
"configuration_checks": [
"defaults"
]
Map the school column from the CSV to school:
"csv": {
"mapping": {
"school_number": "school"
}
}
The CSV can then contain different schools in different rows, for example:
lastname,firstname,person_number,school_number
User1,Test,10001,e915
User2,Test,10002,e999
User3,Test,10003,e134
Run the import without a fixed -s parameter:
/usr/share/ucs-school-import/scripts/ucs-school-user-import \
-c /var/lib/ucs-school-import/configs/<IMPORT>.json \
-i <USERS>.csv \
-l <LOGFILE> \
-u staff \
--dry-run
If one user belongs to multiple schools, do not provide the same user in multiple CSV rows. Multiple rows with the same source_uid and record_uid describe repeated updates of the same user instead of merging the school assignments.
Use the schools attribute in the same row instead, for example:
lastname,firstname,person_number,school_number,schools
User1,Test,10001,e915,"e915,e999"
with an additional mapping:
"schools": "schools"
school defines the primary school, while schools contains the complete school membership.