Skip to content

Commit f395ffb

Browse files
committed
Add ML APIs to client
- Unzip ML integration test data tar archives using SharpZipLib. Add net45 compatible version to Tests - Derive XPackMachineLearningCluster from XPackCluster that seeds ML data and includes additional methods for testing ML APIs - Skip ML integration tests for versions < 5.4.0 - Introduce IntegrationTeardown method to close jobs that may be opened as part of tests - Increase concurrent ML job allocations and max open jobs when starting ML cluster - Explain why certain URL parts are not replaced during code generation Remove special treatment for task_id. This no longer seems to be needed. - Specify node startup timeout on ClusterBase starting up an ML cluster with Fiddler attached could take some time so bump the start timeout for it. - Increase the FAKE process tooling timeout
1 parent ddb8ccb commit f395ffb

File tree

233 files changed

+16442
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+16442
-147
lines changed

build/scripts/Tooling.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module Tooling =
6969
) timeout
7070
code
7171

72-
let private defaultTimeout = TimeSpan.FromMinutes 15.0
72+
let private defaultTimeout = TimeSpan.FromMinutes 20.0
7373

7474
let execProcessInDirectory proc arguments workingDir =
7575
let exitCode = execProcessWithTimeout proc arguments defaultTimeout workingDir
@@ -179,6 +179,7 @@ module Tooling =
179179
Targets = ["Build"]
180180
Properties =
181181
[
182+
"OutputPathBaseDir", Path.GetFullPath "build\\output"
182183
"Optimize", "True"
183184
"Configuration", "Release"
184185
"TargetFrameworkVersion", identifier.MSBuild

paket-files/paket.restore.cached

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
GROUP build
4+
NUGET
5+
remote: https://www.nuget.org/api/v2
6+
Elasticsearch.Net (5.3) - framework: net45
7+
FAKE (4.57.4)
8+
FSharp.Data (2.3.2)
9+
Zlib.Portable (>= 1.11) - framework: >= netstandard11, portable-net45+sl5+win8, portable-net45+win8, portable-net45+win8+wp8+wpa81
10+
NEST (5.3) - framework: net45
11+
Elasticsearch.Net (>= 5.3 < 6.0) - framework: net45, >= net46, >= netstandard13
12+
Newtonsoft.Json (>= 9.0 < 10.0) - framework: net45, >= net46, >= netstandard13
13+
Newtonsoft.Json (9.0.1) - framework: net45
14+
Zlib.Portable (1.11) - framework: >= netstandard11, portable-net45+sl5+win8, portable-net45+win8, portable-net45+win8+wp8+wpa81

src/CodeGeneration/ApiGenerator/ApiGenerator.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private static RestApiSpec CreateRestApiSpecModel(string downloadBranch, string[
5959
if (file.EndsWith("_common.json")) RestApiSpec.CommonApiQueryParameters = CreateCommonApiQueryParameters(file);
6060
else if (file.EndsWith(".obsolete.json")) continue;
6161
else if (file.EndsWith(".patch.json")) continue;
62+
else if (file.EndsWith(".replace.json")) continue;
6263
else
6364
{
6465
var endpoint = CreateApiEndpoint(file);
@@ -74,8 +75,6 @@ private static RestApiSpec CreateRestApiSpecModel(string downloadBranch, string[
7475
return new RestApiSpec { Endpoints = endpoints, Commit = downloadBranch };
7576
}
7677

77-
78-
7978
public static string PascalCase(string s)
8079
{
8180
var textInfo = new CultureInfo("en-US").TextInfo;
@@ -84,6 +83,15 @@ public static string PascalCase(string s)
8483

8584
private static KeyValuePair<string, ApiEndpoint> CreateApiEndpoint(string jsonFile)
8685
{
86+
var replaceFile = Path.Combine(Path.GetDirectoryName(jsonFile), Path.GetFileNameWithoutExtension(jsonFile)) + ".replace.json";
87+
if (File.Exists(replaceFile))
88+
{
89+
var replaceSpec = JObject.Parse(File.ReadAllText(replaceFile));
90+
var endpointReplaced = replaceSpec.ToObject<Dictionary<string, ApiEndpoint>>().First();
91+
endpointReplaced.Value.CsharpMethodName = CreateMethodName(endpointReplaced.Key);
92+
return endpointReplaced;
93+
}
94+
8795
var officialJsonSpec = JObject.Parse(File.ReadAllText(jsonFile));
8896
PatchOfficialSpec(officialJsonSpec, jsonFile);
8997
var endpoint = officialJsonSpec.ToObject<Dictionary<string, ApiEndpoint>>().First();

src/CodeGeneration/ApiGenerator/Domain/ApiEndpoint.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,20 @@ public IEnumerable<string> MethodArguments
1717
get
1818
{
1919
var methodArgs = CsharpMethod.Parts
20-
.Select(p => p.Name != "body" ? "p.RouteValues." + p.Name.ToPascalCase() + (p.Type == "enum" ? ".Value" : "") : "body")
20+
.Select(p =>
21+
{
22+
if (p.Name == "body") return "body";
23+
24+
switch (p.Type)
25+
{
26+
case "enum":
27+
return $"p.RouteValues.{p.Name.ToPascalCase()}.Value";
28+
case "long":
29+
return $"long.Parse(p.RouteValues.{p.Name.ToPascalCase()})";
30+
default:
31+
return $"p.RouteValues.{p.Name.ToPascalCase()}";
32+
}
33+
})
2134
.Concat(new[] {"u => p.RequestParameters"});
2235
return methodArgs;
2336
}

src/CodeGeneration/ApiGenerator/Domain/ApiQueryParameters.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public string CsharpType(string paramName)
4040
case "":
4141
case null:
4242
return "string";
43+
case "date":
44+
return "DateTimeOffset";
4345
case "enum":
4446
return paramName.ToPascalCase();
4547
default:

src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public class ApiUrlPart
1010

1111

1212
private string _description;
13-
public string Description { get { return _description; } set { _description = CleanUpDescription(value); } }
13+
public string Description
14+
{
15+
get => _description;
16+
set => _description = CleanUpDescription(value);
17+
}
1418
public bool Required { get; set; }
1519
public IEnumerable<string> Options { get; set; }
1620

@@ -36,7 +40,12 @@ public string ClrTypeName
3640
return "IndexName";
3741
case "type": return this.Type == "string" ? "TypeName" : "Types";
3842
case "watch_id":
43+
case "job_id":
44+
case "datafeed_id":
45+
case "snapshot_id":
46+
case "filter_id":
3947
case "id": return this.Type == "string" ? "Id" : "Ids";
48+
case "category_id": return "CategoryId";
4049
case "node_id": return this.Type == "string" ? "NodeId" : "NodeIds";
4150
case "scroll_id": return this.Type == "string" ? "ScrollId" : "ScrollIds";
4251
case "field":
@@ -59,6 +68,7 @@ public string ClrTypeName
5968
case "thread_pool_patterns":
6069
return this.Type == "string" ? "Name" : "Names";
6170
case "task_id": return "TaskId";
71+
case "timestamp": return "Timestamp";
6272
default: return this.Type + "_";
6373
}
6474
}

src/CodeGeneration/ApiGenerator/Domain/CsharpMethod.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ public IEnumerable<Constructor> DescriptorConstructors()
226226
generated = $"public {m}({par}) : base(r => r.Required(\"index\", (Indices)typeof({generic}))){{}}";
227227
}
228228

229+
// Use generic T to set the Indices and Types by default in the ctor
230+
if (m == "PutDatafeedDescriptor" || m == "UpdateDatafeedDescriptor")
231+
{
232+
doc = AppendToSummary(doc, ". Will infer the index and type from the generic type");
233+
generated = $"public {m}({par}) : base({routing}){{ Self.Indices = typeof({this.CallTypeGeneric}); Self.Types = typeof({this.CallTypeGeneric}); }}";
234+
}
235+
229236
var c = new Constructor { Generated = generated, Description = doc };
230237
ctors.Add(c);
231238
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
3+
namespace ApiGenerator.Overrides.Descriptors
4+
{
5+
public class FlushJobDescriptorOverrides : DescriptorOverridesBase
6+
{
7+
public override IEnumerable<string> SkipQueryStringParams => new[]
8+
{
9+
"advance_time",
10+
"end",
11+
"start",
12+
"calc_interim",
13+
};
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using ApiGenerator.Domain;
4+
5+
namespace ApiGenerator.Overrides.Descriptors
6+
{
7+
public class GetAnomalyRecordsDescriptorOverrides : DescriptorOverridesBase
8+
{
9+
public override IEnumerable<string> SkipQueryStringParams => new[]
10+
{
11+
"exclude_interim",
12+
"from",
13+
"size",
14+
"start",
15+
"end",
16+
"record_score",
17+
"sort",
18+
"desc"
19+
};
20+
}
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using ApiGenerator.Domain;
4+
5+
namespace ApiGenerator.Overrides.Descriptors
6+
{
7+
public class GetBucketsDescriptorOverrides : DescriptorOverridesBase
8+
{
9+
public override IEnumerable<string> SkipQueryStringParams => new[]
10+
{
11+
"expand",
12+
"exclude_interim",
13+
"from",
14+
"size",
15+
"start",
16+
"end",
17+
"anomaly_score",
18+
"sort",
19+
"desc"
20+
};
21+
}
22+
}

0 commit comments

Comments
 (0)