diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index f134cc04ea24c06c6e8b92b3072cdd93627d1f23..9c845ed637e7b3ed2b214c8851bcd1822919896f 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -10,13 +10,13 @@ function Publish(DataPaths,scriptPath, figure, options) % Location sets the storage location. 'local' sets the storage location % to the current folder (an export folder will be created), 'manual' opens % a explorer window, where you can choose the folder. If you define a export -% path in the config file, this will used per default. +% path in the config file, this will used per defaul (exportPath). % remote path, that is defined in the config file. % Two Methods are implemented 'individual' stores the data for % each plot while 'centralized' uses a data folder and uses reference links % to the original data (hdf5 only). % 'ParentFolder' is the folder Name where the exported data is stored if an -% path is used, PlotId will use this path a storagePath +% path is used, PlotId will use this path as storagePath % 'ConfigFileName' is needed for handling multiple config files (see example) % 'CSV' turns a summary table of all exports on or off % @@ -27,9 +27,9 @@ function Publish(DataPaths,scriptPath, figure, options) arguments DataPaths {mustBeDataPath} % location of the data-file(s) - scriptPath (1,:) {mustBeFile} % location of the matlab script + scriptPath (1,:) {mustBeText} % location of the matlab script figure (1,:) {mustBeFigure} % Checks if figure is a figure object - options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path + options.Location {mustBeMember(options.Location ,{'local','exportPath','manual','CI-Test'})} = 'local' % storage path options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual' options.ParentFolder (1,:) {mustBeText} = 'PlotID_export' % name of the ParentFolder options.ConfigFileName (1,:) {mustBeText} = 'config.json' %individual config names possible @@ -66,6 +66,16 @@ if numel(figure) > 1 warning(msg); end +% find scriptpath +if ~isfile(scriptPath) + scriptPath= which(['/',scriptPath]); + if ~isfile(scriptPath) + msg = ['Script path: ',scriptPath, ' not found on matlab path', newline, ... + '- check spelling or us a path']; + error(msg); + end +end + % catch missing .m extension [~,~, scriptExt] = fileparts(scriptPath); if isempty(scriptExt) @@ -118,13 +128,6 @@ switch options.Location 'does not exist, check the config file - publishing not possible!']; dlgObj.error(msg); end - case 'server' %legacy - if dlgObj.configError - msg = ['Error while reading the config file' newline,... - ' publishing on server not possible']; - dlgObj.error(msg); - end - storPath = configObj.configData.ServerPath; case 'manual' %UI storPath = uigetdir(); case 'CI-Test' %only for CI tests @@ -165,8 +168,8 @@ dlgObj.scriptPublished =status; dlgObj.userMSG(msg); % user functions -[fList,pList] = matlab.codetools.requiredFilesAndProducts(scriptPath); -if options.CopyUserFCN +if options.CopyUserFCN + [fList,pList] = matlab.codetools.requiredFilesAndProducts(scriptPath); fList = fList(~ismember(fList,scriptPath)); % rmv script from list fList = fList(~contains(fList,'config.json')); % rmv config.json from list fList = PlotID.removePltIdFiles(fList); % Do not copy files that are part of PlotID @@ -243,8 +246,9 @@ end meta.ProjectID = ID; meta.CreationDate = datestr(now); meta.MatlabVersion = version; -meta.ToolboxVersions = pList; - +if options.CopyUserFCN + meta.ToolboxVersions = pList; +end % write meta metaPath = fullfile(storPath,folderName,'plotID_data.json'); fid = fopen(char(metaPath),'w'); diff --git a/+PlotID/createLinkedHDF5.m b/+PlotID/createLinkedHDF5.m index 528c354fdd95691851c2990beee8cfa27d4b6144..f04a3b9f01120be4a22de929f30eb0aef6f09501 100644 --- a/+PlotID/createLinkedHDF5.m +++ b/+PlotID/createLinkedHDF5.m @@ -12,10 +12,7 @@ end [~,filename,ext] = fileparts(SourceFile); -try - %old - %fid = H5F.create(fullfile(TargetPath,ID,[ID,'_data.h5'])); - +try fid = H5F.create(fullfile(TargetPath,[filename,ext])); %create External Link to Sourcefile in the Group linkToExternal H5L.create_external(['..',SourceFile],'/',fid, SourceFile ,plist_id,plist_id); diff --git a/.gitignore b/.gitignore index cf430dcb7dbf34695bcd47a8d724367c0da67737..87132438d51d3779d72b495b38b3a3f3697bb1c4 100644 --- a/.gitignore +++ b/.gitignore @@ -27,16 +27,18 @@ codegen/ # Simulink autosave extension *.autosave +# Data files (all .mat and .h5 files) +*.mat +*.h5 + # Personal test files test*.m -test*.h5 cleanUP.m +#test folder +test_*/* # files that are created in example.m -testdata_2.h5 -testdata2.h5 -test_data.mat export/* PlotID_export/* Examples/export/* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..00b4d78bb0e40b64d2c595a8ebd3689aaf384b27 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# V0.3 +- Add changelog +- Add support for file or function name as scriptPath +- Fix a Bug in HDF linking diff --git a/CI_files/runtest.ps1 b/CI_files/runtest.ps1 deleted file mode 100644 index 15d17374764ae708af434eabcfa372828f527be0..0000000000000000000000000000000000000000 --- a/CI_files/runtest.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# runtest.ps1 - -$LOGFILE='CI_log.txt' -$wd = pwd; -$LOGFILE = $("$wd" + "\" + "$LOGFILE") -$CIfolder = "$wd" + "\" + "CI_files\" -# $MFILE='"C:\git\NFDI4ing\plot_ID_matlab\CI_files\runner_test.m"' -$arguments = "-nodesktop", "-nosplash","-minimize","-wait","-sd", "$wd", "-logfile", "$LOGFILE","-batch","CI_files\test_runner_STFS.m" -$Returnvalue = & 'C:\Program Files\MATLAB\R2021b\bin\matlab.exe' $arguments - -#$CODE = $? -# Returnvalue doesnt get anything useful from matlab -# Write-Output($Returnvalue) -Write-Output(Get-Content($LOGFILE)) - -exit $CODE - diff --git a/README.md b/README.md index 929ac878932aafd14616caa66ecc8e6cfceb1796..4999db61898459829c6241e3f906936d3d0a8fec 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ The **ProjectID** is your custom project number, it well be the prefix of the ID 2. Publish the plot and the associated data `PlotID.Publish(DataPaths,scriptPath, figure, options)` -`scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']` \ -`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path). \ +`scriptPath` contains either the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']` or the script or function name that is used for creating your plot. \ +`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell array (they must be at the path). \ `figure` is the figure that should be published.