-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
84 lines (73 loc) · 2.59 KB
/
Program.cs
File metadata and controls
84 lines (73 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using Flowthru.Core.Cli;
using Flowthru.Core.Services;
using Flowthru.Extensions.Spark;
using Flowthru.Extensions.Spark.Services;
using Flowthru.Meta;
using Flowthru.Meta.Providers;
using KedroSpaceflightsSpark.Data;
using KedroSpaceflightsSpark.Flows.DataProcessing;
using KedroSpaceflightsSpark.Flows.DataScience;
using KedroSpaceflightsSpark.Flows.Reporting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace KedroSpaceflightsSpark;
public class Program
{
public static Task<int> Main(string[] args) =>
FlowthruCli.RunStandaloneAsync(
args,
services => ConfigureServices(services, Directory.GetCurrentDirectory())
);
public static IServiceProvider ConfigureServices(string? basePath = null)
{
var services = new ServiceCollection();
ConfigureServices(services, basePath ?? Directory.GetCurrentDirectory());
return services.BuildServiceProvider();
}
private static void ConfigureServices(IServiceCollection services, string basePath)
{
services.AddFlowthru(flowthru =>
{
flowthru.UseConfiguration(opts => opts.ConfigurationPath = basePath);
flowthru.RegisterCatalog<Catalog>(sp => new Catalog(
Path.Combine(basePath, "Data"),
sp.GetRequiredService<SparkFrameProvider>()
));
flowthru.ConfigureMetadata(meta =>
{
var metadataPath = Path.Combine(basePath, "Metadata");
meta.AddProvider<JsonMetadataProvider, JsonMetadataProviderBuilder>(json =>
json.WithOutputDirectory(metadataPath)
)
.AddProvider<MermaidMetadataProvider, MermaidMetadataProviderBuilder>(mermaid =>
mermaid.WithOutputDirectory(metadataPath)
);
});
flowthru
.RegisterFlow(label: "DataProcessing", flow: DataProcessingFlow.Create)
.WithDescription(
"Preprocesses companies, shuttles, and reviews data using Spark DataFrames"
);
flowthru
.RegisterFlow(
label: "DataScience",
flow: DataScienceFlow.Create,
configurationSection: "Flowthru:Flows:DataScience"
)
.WithDescription("Trains linear regression model for price prediction");
flowthru
.RegisterFlow(
label: "Reporting",
flow: ReportingFlow.Create,
configurationSection: "Flowthru:Flows:Reporting"
)
.WithDescription("Generates passenger capacity reports and visualizations");
flowthru.UseSpark();
});
services.AddLogging(logging =>
{
logging.AddConsole();
logging.SetMinimumLevel(LogLevel.Information);
});
}
}