From c7256d2d1d61a65c5a5865f448c056e34f560df6 Mon Sep 17 00:00:00 2001 From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de> Date: Wed, 1 Dec 2021 09:09:15 +0100 Subject: [PATCH] Clean Up and additions --- .gitignore | 5 +++ CI_files/default_test.m | 8 ++--- CI_files/fail_runner.m | 8 +++++ CI_files/pass_runner.m | 8 +++++ CI_files/runner_linux.sh | 15 ++++++++ CI_files/runtest.ps1 | 17 +++++++++ PlotID_Demo.m | 74 ---------------------------------------- example-config.json | 5 --- 8 files changed, 57 insertions(+), 83 deletions(-) create mode 100644 CI_files/fail_runner.m create mode 100644 CI_files/pass_runner.m create mode 100644 CI_files/runner_linux.sh create mode 100644 CI_files/runtest.ps1 delete mode 100644 PlotID_Demo.m delete mode 100644 example-config.json diff --git a/.gitignore b/.gitignore index 871929a..cf430dc 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,9 @@ testdata_2.h5 testdata2.h5 test_data.mat export/* +PlotID_export/* Examples/export/* +Examples/PlotID_export/* unused*/* # Octave session info @@ -46,3 +48,6 @@ octave-workspace #logs log.txt + +# csvs +*.csv diff --git a/CI_files/default_test.m b/CI_files/default_test.m index 726c59a..ae9826f 100644 --- a/CI_files/default_test.m +++ b/CI_files/default_test.m @@ -14,10 +14,10 @@ addpath('CI_files'); % clean up, if previous run failed try - delete(['CI_files' filesep 'export' filesep '*']); + delete(['CI_files' filesep 'PlotID_export' filesep '*']); delete(['CI_files' filesep '*.mat']); delete(['CI_files' filesep '*.h5']); - rmdir(['CI_files' filesep 'export'],'s'); + rmdir(['CI_files' filesep 'PlotID_export'],'s'); end % initialise @@ -116,10 +116,10 @@ fclose(fid); % final clean up try - delete(['CI_files' filesep 'export' filesep '*']); + delete(['CI_files' filesep 'PlotID_export' filesep '*']); delete(['CI_files' filesep '*.mat']); delete(['CI_files' filesep '*.h5']); - rmdir(['CI_files' filesep 'export'],'s'); + rmdir(['CI_files' filesep 'PlotID_export'],'s'); delete(fullfile('CI_files','CI_config.json')); end diff --git a/CI_files/fail_runner.m b/CI_files/fail_runner.m new file mode 100644 index 0000000..e9071dd --- /dev/null +++ b/CI_files/fail_runner.m @@ -0,0 +1,8 @@ +function [retVal] = fail_runner() +%RUNNER_TESTING testing function to test, if the runner is set up properly + retVal = 1; % test should fail ! + fid = fopen(fullfile('log.txt'),'w'); + txt = ['This is a test, Errorstate: ', num2str(retVal)]; + fprintf(fid,txt); + fclose(fid); +end diff --git a/CI_files/pass_runner.m b/CI_files/pass_runner.m new file mode 100644 index 0000000..9572685 --- /dev/null +++ b/CI_files/pass_runner.m @@ -0,0 +1,8 @@ +function [retVal] = pass_runner() +%pass_runner testing function to test, if the runner is set up properly + retVal = 0; % test should succeed ! + fid = fopen(fullfile('log.txt'),'w'); + txt = ['This is a test, Errorstate: ', num2str(retVal)]; + fprintf(fid,txt); + fclose(fid); +end diff --git a/CI_files/runner_linux.sh b/CI_files/runner_linux.sh new file mode 100644 index 0000000..f64784c --- /dev/null +++ b/CI_files/runner_linux.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +#matlab -r "disp(['Current folder: ' pwd])" +matlab $@ -nodisplay -nodesktop -nosplash -logfile matlab_log.txt -r "default_test;exit(ans);" + +exitstatus=$? +if [[ $exitstatus -eq '0' ]] +then + echo "matlab succeed. Exitstatus: $exitstatus" + exit $exitstatus +else + echo "matlab failed. Exitstatus: $exitstatus" + exit $exitstatus + +fi diff --git a/CI_files/runtest.ps1 b/CI_files/runtest.ps1 new file mode 100644 index 0000000..15d1737 --- /dev/null +++ b/CI_files/runtest.ps1 @@ -0,0 +1,17 @@ +# 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/PlotID_Demo.m b/PlotID_Demo.m deleted file mode 100644 index 766ad17..0000000 --- a/PlotID_Demo.m +++ /dev/null @@ -1,74 +0,0 @@ -%% Example Script -% This Script is meant to demonstrate the capabilities of the PlotID tool. - -%% Clear Environment -clear; clc; close all; -addpath('CI_files'); % Test scripts -try - delete testdata2.h5; -end - -%% Set ProjectID -% ProjectID can also be set in the config file -% Leave empty for using the ID from the config file -ProjectID = 'FST01'; - -%% Data -% Creating Random Data to use as data-file -x = linspace(0,7); -y = rand(1,100)+2; -dataset1 = 'test_data.mat'; -% use absolute paths for good practise -dataset1 = fullfile(pwd, dataset1); -save(dataset1,'x','y'); - -% some data as .h5 -x1 = linspace(0,2*pi); -y1 = sin(x1)+.5*sin(2*x1)+2; - -% define file path & name - -fpath = fullfile(pwd,"./testdata2.h5"); -dataset2 = fullfile(pwd,'testdata2.h5'); - -% create hdf5 file and dataset > write data to hdf5 file / dataset -h5create(fpath, "/x1", size(x1), "Datatype", class(x1)) -h5create(fpath, "/y1", size(y1), "Datatype", class(y1)) -h5write(fpath, "/x1", x1) -h5write(fpath, "/y1", y1) - -%% Plotting -% This is still part of a normal script to produce plots. -% Make sure to save each figure in a variable to pass to PlotID-functions. -fig(1) = figure; -set(gcf,'Units','centimeters','PaperUnits','centimeters','PaperSize',[9 7],... -'Position',[5 5 9 7]); -plot(x,y,'Color',0.5*[1 1 1]); -box off; hold on; -plot(x1,y1,'-k'); -set(gca, 'TickDir', 'out', 'YLim', [0,4],'YTick',[0:1:4],'XLim',[0,6]); -%fstplt.setfiguresize('1/2ppt16:9'); -%fstplt.pimpplot; - -%% Example 1: single plot based on two data-sets - -%% Tag the plot -% PlotID Implementation starts here. -% TagPlot adds a visible ID to the figure(s) and to the figures property -% 'Tag' -[fig, ID] = PlotID.TagPlot(fig, 'ProjectID', ProjectID); - -%% Publishing -% Second part of plotID -% The functions needs the file location, the location of the data and the -% figure and can take several options. -path.script = mfilename('fullpath'); % filename of the m.script -% file names of the datasets -path.rdata = {dataset1,dataset2} ; % don't forget the extension - -PlotID.Publish(path, ID, fig(1), 'Location', 'local' ,'Method','individual') - - - -%% End - diff --git a/example-config.json b/example-config.json deleted file mode 100644 index 92b8621..0000000 --- a/example-config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Author": "Example Author", - "ProjectID": "AB01", - "ServerPath": "\\\\Server\\path\\folder" -} -- GitLab