Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rdmp 73 cohort holdouts #1653

Merged
merged 30 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8d694ca
add top to cohort
JFriel Oct 13, 2023
dc27f96
working holdout flow
JFriel Oct 16, 2023
16a4470
interim
JFriel Oct 16, 2023
8baaee2
basic ui flow
JFriel Oct 16, 2023
6917804
now filtering
JFriel Oct 16, 2023
0b5c983
working flow
JFriel Oct 16, 2023
3e7ba3a
working auto-holdout
JFriel Oct 17, 2023
49ed3b2
fix test
JFriel Oct 17, 2023
5948f79
Merge branch 'develop' of https://github.com/HicServices/RDMP into fe…
JFriel Oct 18, 2023
d318a3d
add query
JFriel Oct 18, 2023
8e22249
improved holdout
JFriel Oct 20, 2023
a327171
tidy up code
JFriel Oct 20, 2023
bbea3ee
add description
JFriel Oct 20, 2023
0286883
revert test db
JFriel Oct 20, 2023
50b86c7
add holdout description
JFriel Oct 20, 2023
8d5ada5
add todo
JFriel Oct 20, 2023
25fa9be
Merge branch 'develop' into feature/RDMP-73-cohort-holdouts
jas88 Oct 26, 2023
ac74e48
fixups from codeql
JFriel Oct 27, 2023
2c9da25
Minor syntax fix
jas88 Oct 28, 2023
1fd6047
Fix possible null deref
Oct 28, 2023
9deee83
Merge branch 'develop' into feature/RDMP-73-cohort-holdouts
JFriel Oct 30, 2023
e61c076
Merge branch 'develop' of https://github.com/HicServices/RDMP into fe…
JFriel Oct 30, 2023
0b4eea7
Merge branch 'develop' into feature/RDMP-73-cohort-holdouts
JFriel Nov 1, 2023
e8caf21
fix todo url
JFriel Nov 2, 2023
6ee38cd
Merge branch 'feature/RDMP-73-cohort-holdouts' of https://github.com/…
JFriel Nov 2, 2023
f838887
Merge branch 'develop' into feature/RDMP-73-cohort-holdouts
JFriel Nov 6, 2023
95c189d
Merge branch 'develop' into feature/RDMP-73-cohort-holdouts
jas88 Nov 6, 2023
4a7cefa
Tidy, typo fix
jas88 Nov 9, 2023
f3415ed
Merge branch 'develop' into feature/RDMP-73-cohort-holdouts
jas88 Nov 9, 2023
b58a1c6
Remove disused field
Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@ public void StartSession(string sessionName, IEnumerable<IMapsDirectlyToDatabase

public override IPipelineRunner GetPipelineRunner(DialogArgs args, IPipelineUseCase useCase, IPipeline pipeline)
{

if(useCase is not null && pipeline is not null)
{
return new PipelineRunner(useCase, pipeline);
}
var configureAndExecuteDialog = new ConfigureAndExecutePipelineUI(args, useCase, this)
{
Dock = DockStyle.Fill
Expand All @@ -856,9 +861,28 @@ public override CohortCreationRequest GetCohortCreationRequest(ExternalCohortTab
return ui.ShowDialog() == DialogResult.OK ? ui.Result : null;
}

public override CohortHoldoutLookupRequest GetCohortHoldoutLookupRequest(ExternalCohortTable externalCohortTable, IProject project, CohortIdentificationConfiguration cic)
{
// if on wrong Thread
if (_mainDockPanel?.InvokeRequired ?? false)
return _mainDockPanel.Invoke(() =>
GetCohortHoldoutLookupRequest(externalCohortTable, project, cic));

var ui = new Rdmp.UI.CohortUI.CreateHoldoutLookup.CreateHoldoutLookupUI(this, externalCohortTable, project, cic);

if (!string.IsNullOrWhiteSpace(cic.Description))
ui.CohortDescription = $"{cic.Description} ({Environment.UserName} - {DateTime.Now})";
//todo the ui portion does not work currently
return ui.ShowDialog() == DialogResult.OK ? ui.Result : ui.Result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this should be ui.Result:null like the method above, instead of returning the result regardless of the user action?

}

public override ICatalogue CreateAndConfigureCatalogue(ITableInfo tableInfo,
ColumnInfo[] extractionIdentifierColumns, string initialDescription, IProject projectSpecific, string folder)
{
if(extractionIdentifierColumns is not null)
{
return base.CreateAndConfigureCatalogue(tableInfo, extractionIdentifierColumns, initialDescription, projectSpecific, folder);
}
// if on wrong Thread
if (_mainDockPanel?.InvokeRequired ?? false)
return _mainDockPanel.Invoke(() => CreateAndConfigureCatalogue(tableInfo, extractionIdentifierColumns,
Expand Down
60 changes: 60 additions & 0 deletions Rdmp.Core/CohortCommitting/Pipeline/CohortHoldoutLookupRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) The University of Dundee 2018-2019
// This file is part of the Research Data Management Platform (RDMP).
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Globalization;
using System.Security.Permissions;
using NPOI.SS.Formula.Functions;
using Rdmp.Core.Curation.Data.Cohort;
using Rdmp.Core.Curation.Data.Pipelines;
using Rdmp.Core.DataFlowPipeline.Requirements;
using Rdmp.Core.MapsDirectlyToDatabaseTable;

namespace Rdmp.Core.CohortCommitting.Pipeline;

/// <summary>
/// All metadata details nessesary to create a cohort including which project it goes into, its name, version etc. There are no identifiers for the cohort.
/// Also functions as the use case for cohort creation (to which it passes itself as an input object).
/// </summary>
public sealed class CohortHoldoutLookupRequest : PipelineUseCase, ICanBeSummarised, ICohortHoldoutLookupRequest
{
public CohortIdentificationConfiguration CIC { get; set; }
public int Count { get; set; }
public bool IsPercent { get; set; }

public string DescriptionForAuditLog { get; set; }

public string Name { get; set; }

public DateTime MinDate { get; set; }
public DateTime MaxDate { get; set; }
public string DateColumnName { get; set; }
public CohortHoldoutLookupRequest(CohortIdentificationConfiguration cic, string name, int count, bool isPercent, string descriptionForAuditLog,string minDate=null,string maxDate=null,string dateColumnName=null)
{
CIC = cic;
Name = name;
Count = count;
IsPercent = isPercent;
DescriptionForAuditLog = descriptionForAuditLog;
DateTime _MinDate;
DateTime.TryParseExact(minDate, "DD/MM/YYYY", new CultureInfo("en-GB"), DateTimeStyles.None,out _MinDate);
MinDate = _MinDate;
DateTime _MaxDate;
DateTime.TryParseExact(maxDate, "DD/MM/YYYY", new CultureInfo("en-GB"), DateTimeStyles.None, out _MaxDate);
Copy link
Member

@jas88 jas88 Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor C# tip for the future: you can do that inline as "out var foo" instead of "DateTime foo; ... out foo", and you can write straight to the target instead of doing "out var tmp; foo = tmp;" (if it's a variable not a property!)

MinDate = _MinDate;
DateColumnName = dateColumnName;
AddInitializationObject(this);
}
public string GetSummary(bool includeName, bool includeId)
{
throw new NotImplementedException();
}

protected override IDataFlowPipelineContext GenerateContextImpl()
{
throw new NotImplementedException();
}
}
12 changes: 12 additions & 0 deletions Rdmp.Core/CohortCommitting/Pipeline/ICohortHoldoutLookupRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rdmp.Core.CohortCommitting.Pipeline
{
internal interface ICohortHoldoutLookupRequest
{
}
}
2 changes: 2 additions & 0 deletions Rdmp.Core/CommandExecution/AtomicCommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ public IEnumerable<IAtomicCommand> CreateCommands(object o)

yield return new ExecuteCommandFreezeCohortIdentificationConfiguration(_activator, cic, !cic.Frozen)
{ Weight = -50.5f };
yield return new ExecuteCommandCreateHoldoutLookup(_activator, cic, ac)
{ Weight = -50.5f };

var clone = new ExecuteCommandCloneCohortIdentificationConfiguration(_activator)
{ Weight = -50.4f, OverrideCommandName = "Clone" }.SetTarget(cic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
{
private readonly DiscoveredDatabase _targetDatabase;
private IPipeline _pipeline;
private string _extractionIdentifier;

Check notice

Code scanning / CodeQL

Missed 'readonly' opportunity Note

Field '_extractionIdentifier' can be 'readonly'.

public FileInfo File { get; private set; }

Expand Down Expand Up @@ -63,10 +64,12 @@
Pipeline pipeline,
[DemandsInitialization(Desc_ProjectSpecificParameter)]
Project projectSpecific) : base(activator, projectSpecific, null)

{
File = file;
_targetDatabase = targetDatabase;
_pipeline = pipeline;
_extractionIdentifier = extractionIdentifier;
UseTripleDotSuffix = true;
CheckFile();
}
Expand Down Expand Up @@ -150,11 +153,20 @@

var importer = new TableInfoImporter(BasicActivator.RepositoryLocator.CatalogueRepository, tbl);
importer.DoImport(out var ti, out _);

var cata = BasicActivator.CreateAndConfigureCatalogue(ti, null,
ICatalogue cata;
if (_extractionIdentifier is not null)
{
ColumnInfo[] extractionIdentifiers = ti.ColumnInfos.Where(ti => ti.Name == _extractionIdentifier).ToArray();
cata = BasicActivator.CreateAndConfigureCatalogue(ti, extractionIdentifiers,
$"Import of file '{File.FullName}' by {Environment.UserName} on {DateTime.Now}", ProjectSpecific,
TargetFolder);

}
else
{
cata = BasicActivator.CreateAndConfigureCatalogue(ti, null,
$"Import of file '{File.FullName}' by {Environment.UserName} on {DateTime.Now}", ProjectSpecific,
TargetFolder);
}
if (cata != null)
{
Publish(cata);
Expand Down
Loading
Loading