Skip to content

Commit

Permalink
working auto-holdout
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Oct 17, 2023
1 parent 0b5c983 commit 3e7ba3a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
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 Down Expand Up @@ -874,6 +879,10 @@ public override CohortHoldoutLookupRequest GetCohortHoldoutLookupRequest(Externa
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ExecuteCommandCreateNewCatalogueByImportingFile : CatalogueCreation
{
private readonly DiscoveredDatabase _targetDatabase;
private IPipeline _pipeline;
private string _extractionIdentifier;

public FileInfo File { get; private set; }

Expand Down Expand Up @@ -63,10 +64,12 @@ public ExecuteCommandCreateNewCatalogueByImportingFile(IBasicActivateItems activ
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 @@ private void OnPipelineCompleted(object sender, PipelineEngineEventArgs args, Di

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
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ private static DialogArgs GetChooseCohortDialogArgs() =>
AllowAutoSelect = true
};


private static DialogArgs GetChooseExtractionIdentifier() =>
new()
{
WindowTitle = "Choose Extraction Identifier",
TaskDescription =
"TODO",
EntryLabel = "Choose Extraction Identifier",
AllowAutoSelect = true
};

private DataTable LoadDataTable(DiscoveredServer server, string sql)
{

Expand All @@ -95,15 +84,12 @@ private DataTable LoadDataTable(DiscoveredServer server, string sql)
con.Open();

_cmd = server.GetCommand(sql, con);
_cmd.CommandTimeout = 10000;// _timeoutControls.Timeout;
_cmd.CommandTimeout = 10000;

var a = server.GetDataAdapter(_cmd);

a.Fill(dt);

//MorphBinaryColumns(dt);

//Invoke(new MethodInvoker(() => { dataGridView1.DataSource = dt; }));
con.Close();
}
catch (Exception)
Expand Down Expand Up @@ -229,12 +215,7 @@ public override void Execute()
fi
};
FileCollectionCombineable fcc = new FileCollectionCombineable(fil);
//File = file;
//_targetDatabase = targetDatabase;
//_pipeline = pipeline;
//UseTripleDotSuffix = true;
//CheckFile();
//extraction identifier

List<string> columns = new List<string>();
foreach (DataColumn column in _dataTable.Columns)
{
Expand All @@ -243,14 +224,10 @@ public override void Execute()


var extractionIdentifier = "";
BasicActivator.SelectObject("Select", columns.ToArray(), out extractionIdentifier);
//target db
DiscoveredDatabase db = SelectDatabase(true, "todo");
//pipeline
BasicActivator.SelectObject("Select an Extraction Identifier", columns.ToArray(), out extractionIdentifier);
DiscoveredDatabase db = SelectDatabase(true, "Select a Database to store the new Holdout.");
var pipe = _activator.RepositoryLocator.CatalogueRepository.GetAllObjects<Pipeline>().OrderByDescending(p => p.ID)
.FirstOrDefault(p => p.Name.Contains("BULK INSERT: CSV Import File (automated column-type detection)"));
//project specific
//todo

var z = new ExecuteCommandCreateNewCatalogueByImportingFile(_activator, fi, extractionIdentifier, db, pipe, null);
z.Execute();
Expand All @@ -262,6 +239,5 @@ public override void Execute()

}

public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
Image.Load<Rgba32>(CatalogueIcons.FrozenCohortIdentificationConfiguration);
public override Image<Rgba32> GetImage(IIconProvider iconProvider) => iconProvider.GetImage(RDMPConcept.CohortAggregate,OverlayKind.Link);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public CreateHoldoutLookupUI(IActivateItems activator, IExternalCohortTable targ
taskDescriptionLabel1.SetupFor(new DialogArgs
{
TaskDescription =
"todo. maybe remove?"
"Holdouts...do stuff todo"
});
}

Expand Down

0 comments on commit 3e7ba3a

Please sign in to comment.