%% 1. Point at the venv (always needed fresh after restart) pyenv('Version', '/Users/bartels-rausch/matlab-pybis-venv/bin/python3') %% 2. Import (first time this session -- guaranteed to read from disk) py.sys.path().append('/Users/bartels-rausch'); py.importlib.import_module('nappSyncToOpenbis'); %% 3. Your connection details openbisUrl = "https://openbis-psi.labnotebook.ch"; spaceCode = "5505_BEAMTIMES"; collectionId = []; objectType = "LAC_EXPERIMENTAL_STEP_BEAMTIME"; parentIdentifier = "/5505_BEAMTIMES/ENTRY783"; verifyCertificates = false; username = "bartels-rausch_admin"; password = input('openBIS password: ', 's'); clc %% 4. Rebuild the test data (also fresh, in case anything upstream changed) testRows = FileList(11:12,:); metaCols = {'name','folder','creationDate','lastModifiedDatenum','sample', ... 'sampleTemp_dC','cellPressure_mbar','iceTemp_dC','comment','regionName', ... 'scientaLensMode','scientaAcquisitionMode','scientaDwellTime_ms', ... 'scientaPassEnergy_eV','scientaSequenceIterations','scientaRegionIterations', ... 'scientaEkinStep_eV','xRayEkin_eV','xRayEkinRange_eV','scientaEkinRange_eV', ... 'smplX_mm','smplY_mm','smplZ_mm'}; metaCols = intersect(metaCols, testRows.Properties.VariableNames, 'stable'); testTable = testRows(:, metaCols); testTable.resultImages = repmat({{}}, height(testTable), 1); rowsJsonTest = jsonencode(table2struct(testTable)); campaignProps = struct( ... 'campaignLocation', FileList.Properties.CustomProperties.campaignLocation, ... 'team', FileList.Properties.CustomProperties.team, ... 'projectName', FileList.Properties.CustomProperties.projectName); campaignPropsJson = jsonencode(campaignProps); %% 5. The actual test resultJson = py.nappSyncToOpenbis.sync_rows(rowsJsonTest, openbisUrl, spaceCode, ... pyargs('collection', collectionId, 'object_type', objectType, ... 'username', username, 'password', password, ... 'campaign_props_json', campaignPropsJson, 'upload_files', false, ... 'parent_identifier', parentIdentifier, ... 'verify_certificates', verifyCertificates)); results = struct2table(jsondecode(char(resultJson))); disp(results.message{1})