Package: didis
DIDIS - Desy ITk Database Interaction ScriptDIDIS is a Python script meant to ease interaction with the ATLAS ITk Production Database (DB) for the detector (pre-)production efforts at DESY-HH.InstallationPip users can get the package by issuingpipinstalldidisOn some systems, usepip3instead ofpip.RequirementsDIDIS is based onpython3. You can install all requirements at once by issuingpip install --user requests argh loguru itkdbWhen you install via pip, it will be done for you during the intalltion.AuthenticationThe DB required two user specific access codes to authenticate the user. For security reasons, these should not be stored on the disk. They are stored in the environment variablesITKDB_ACCESS_CODE1andITKDB_ACCESS_CODE2. In linux, they can be set for the current terminal session like this:exportITKDB_ACCESS_CODE1=YourFirstPasswordexportITKDB_ACCESS_CODE2=YourSecondPasswordor for WindowssetITKDB_ACCESS_CODE1=YourFirstPasswordsetITKDB_ACCESS_CODE2=YourSecondPasswordCheck whether the authentication is working by callingdidis authenticateLooking up components in the DBWith DIDIS, the ITk DB can be searched for all sorts of keys, not only for serial numbers. The tool "lookup" does exactly this and outputs the DB codes.didislookup-v20USEBT1098765--printJSONlooks up a Bus Tape with the ATLAS SN  20USEBT1098765 and prints the component info in human readable JSON. The subproject, component type and lookup key can also be changed using the optional arguments. Call the script with--helpfor more info.
By passing the option--returnResults, the function returns a dictionary that either appears as the CLI output or can be used by the calling function.Attaching a file to a componentTo attach a file from your local file system to a component with ID CID, usedidisattachresults.zipCIDThe ID can be found using thelookupcommand.Setting the production stageSetting the production stage of a component with ATLAS serial number SN to STAGE is done viadidisstageSN-sSTAGELeaving the-sargument just prints the current production stage without changing anything.Get all available tests for a component typeGet all available tests for type "BT":didistets--componentTypeBTGet a test skeleton JSONGet a bare test JSON for a given test type:didisskeleton--testBTELECTRICAL--componentTypeBTUsing--returnResultsmakes the skeleton available as a dict via the function return.Upload a test result to the DBThecontentfield requires to be set to the ATLAS serial number, not to the component ID
To upload a JSON test result to the DB, usedidisuploadFILE.jsonWhen not using the CLI, the function can also convert a dict directly.Get all test results associated with a componentTo get a dict with all test results for a given component id, usedidistestrunsDB_COMPONENT_IDYou can find the component id using thelookupcommand.Attaching a file to a test runTo attach a file from your local file system to a test run with ID TID, usedidistestfileresults.zipTIDThe ID can be found using thetestrunscommand.Usage in another Python scriptTo use the functions in thedidis.pyscript, use the importimportdidis.didisasddRegistering new ComponentsMake an Excel file with all the properties and serial numbers and register them all viadidis-batchregisterYOUREXCELFILEStart batch identifiers withB_.Assembling ComponentsAssemble a child component to a parent usingdidisassemblePARENT_SERIAL_NUMBERCHILD_SERIAL_NUMBERIf the component has no ATLAS serial number, use the alternative identifier instead. Specify this using the--parentAIDand--childAIDflags. Optionally, a.jsonfile or dict can be passed to thepropertiesinput.Changing Component propertiesTo change a component property, usedidispropertyCOMPONENT_IDPROPERTY_IDVALUEThe component ID can also be a ATLAS serial number.Adding a comment to a component / testTo add a comment to a component, usedidiscommentCOMPONENT_SERIAL_OR_ID"COMMENT_STRING"To add a comment to a test run, usedidiscommentTEST_ID"COMMENT_STRING"--isTestTODO: When only adding one comment, the DB throws an error. An additional empty comment is created as a workaround as of nowCreating a shipmentTo add a new shipment, usedidisshipCOMPONENT_ID--OPTIONS