Skip to content

Commit d604086

Browse files
committed
upgrade to .Net 5
1 parent 745d8e8 commit d604086

File tree

14 files changed

+16
-104
lines changed

14 files changed

+16
-104
lines changed

.github/workflows/new-csharp-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
if: ${{ !contains(fromJson(steps.fetch_all_releases.outputs.all_releases).*.tag_name, steps.fetch_current_version.outputs.current_version) }}
4242
uses: actions/setup-dotnet@v1
4343
with:
44-
dotnet-version: 3.1.301
44+
dotnet-version: 5.0.405
4545

4646
# - name: Setup .NET Core # required by ClientSDK
4747
# if: ${{ !contains(fromJson(steps.fetch_all_releases.outputs.all_releases).*.tag_name, steps.fetch_current_version.outputs.current_version) }}

.github/workflows/nuget-pack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup .NET Core # required by the `gpr` tool
1919
uses: actions/setup-dotnet@v1
2020
with:
21-
dotnet-version: 3.1.301
21+
dotnet-version: 5.0.405
2222

2323
# - name: Setup .NET Core # required by ClientSDK
2424
# uses: actions/setup-dotnet@v1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a Client SDK for RelationalAI
44

5-
- API version: 1.2.5
5+
- API version: 1.2.6
66

77
## Frameworks supported
88

RelationalAI/Connection.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,6 @@ public bool EnableLibrary(string srcName)
364364
return Client.EnableLibrary(srcName);
365365
}
366366

367-
public bool CloseDatabase()
368-
{
369-
SetConnectionOnClients();
370-
return Client.CloseDatabase();
371-
}
372-
373367
public ICollection<Relation> Cardinality(string relName = null)
374368
{
375369
SetConnectionOnClients();

RelationalAI/GeneratedRelationalAIClient.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,6 @@ public System.Collections.Generic.IDictionary<string, object> AdditionalProperti
842842
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.24.0 (Newtonsoft.Json v12.0.0.0)")]
843843
public partial class ModifyWorkspaceAction : Action
844844
{
845-
[Newtonsoft.Json.JsonProperty("close_database", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
846-
public string Close_database { get; set; }
847-
848845
[Newtonsoft.Json.JsonProperty("delete_edb", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
849846
public string Delete_edb { get; set; }
850847

RelationalAI/HttpClientFactory.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public static HttpClient CreateHttpClient(bool verifySSL, int timeout) {
3131
if( verifySSL ) {
3232
var handler = new SocketsHttpHandler()
3333
{
34-
// uncomment this to enable keep-alive after moving to netcore5
35-
// ConnectCallback = s_defaultConnectCallback,
34+
ConnectCallback = s_defaultConnectCallback,
3635
};
3736
HttpClient httpClient = new HttpClient(handler);
3837
httpClient.Timeout = TimeSpan.FromSeconds(timeout);
@@ -49,8 +48,7 @@ public static HttpClient CreateHttpClient(bool verifySSL, int timeout) {
4948
};
5049
var handler = new SocketsHttpHandler()
5150
{
52-
// uncomment this to enable keep-alive after moving to netcore5
53-
// ConnectCallback = s_defaultConnectCallback,
51+
ConnectCallback = s_defaultConnectCallback,
5452
SslOptions = sslOptions
5553
};
5654
HttpClient httpClient = new HttpClient(handler);
@@ -121,8 +119,7 @@ private static Socket CreateSocket(EndPoint endPoint)
121119
return socket;
122120
}
123121

124-
/*
125-
// uncomment this block to enable keep-alive after moving to netcore5
122+
126123
private static async ValueTask<Stream> DefaultConnectAsync(SocketsHttpConnectionContext context, CancellationToken cancellationToken)
127124
{
128125
// `Socket.SetSocketOption` function fails if a `DnsEndPoint` is passed, as it
@@ -146,7 +143,7 @@ private static async ValueTask<Stream> DefaultConnectAsync(SocketsHttpConnection
146143
}
147144
}
148145
private static readonly Func<SocketsHttpConnectionContext, CancellationToken, ValueTask<Stream>> s_defaultConnectCallback = DefaultConnectAsync;
149-
*/
146+
150147

151148
private async static ValueTask<IPEndPoint> getIPEndPoint(DnsEndPoint dnsEndPoint)
152149
{

RelationalAI/KGMSClient.cs

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public partial class GeneratedRelationalAIClient
2121

2222
public const string JSON_CONTENT_TYPE = "application/json";
2323
public const string CSV_CONTENT_TYPE = "text/csv";
24-
public const string USER_AGENT_HEADER = "KGMSClient/1.2.5/csharp";
24+
public const string USER_AGENT_HEADER = "KGMSClient/1.2.1/csharp";
2525

2626
public int DebugLevel = Connection.DEFAULT_DEBUG_LEVEL;
2727

@@ -78,25 +78,6 @@ partial void PrepareRequest(Transaction body, HttpClient client, HttpRequestMess
7878

7979
// use HTTP 2.0 (to handle keep-alive)
8080
request.Version = System.Net.HttpVersion.Version20;
81-
82-
// have a separate keep-alive task (per thread)
83-
if(!isStatusRequest(body)) {
84-
var tokenSource = new CancellationTokenSource();
85-
AsyncLocalKeepAliveCancellationTokenSource.Value = tokenSource;
86-
CancellationToken ct = tokenSource.Token;
87-
88-
/**
89-
* TODO: currently we swallo exceptions in KeepClientAlive.
90-
* If we want to throw, then we need to change this to asynchronously handle the throw
91-
* e.g.
92-
* try {
93-
await this.KeepClientAlive(client, url, ct).ConfigureAwait(false);
94-
} catch (Exception e) {
95-
// Handle here
96-
}
97-
**/
98-
var keep_alive_task = this.KeepClientAlive(client, url, ct).ConfigureAwait(false);
99-
}
10081
}
10182

10283
private bool isStatusRequest(Transaction txn)
@@ -127,11 +108,6 @@ private bool _isEmpty(string str)
127108
{
128109
return str == null || str.Length == 0;
129110
}
130-
131-
public virtual Task KeepClientAlive(HttpClient client_, String url, CancellationToken ct)
132-
{
133-
throw new NotImplementedException();
134-
}
135111
}
136112

137113
public partial class Transaction
@@ -356,46 +332,6 @@ public ILogger Logger
356332
}
357333
private ILogger _logger;
358334

359-
public override async Task KeepClientAlive(HttpClient client_, String url, CancellationToken ct)
360-
{
361-
while (true)
362-
{
363-
ct.ThrowIfCancellationRequested();
364-
await Task.Delay(HttpClientFactory.KEEP_ALIVE_INTERVAL*1000);
365-
ct.ThrowIfCancellationRequested();
366-
367-
try {
368-
await Task.Run(() => this.KeepAliveProbe(client_, ct));
369-
} catch (Exception e) {
370-
// ignore. But I think we might want to throw?
371-
Logger.Error("KeepAliveProbe failed with exception: " + e.Message);
372-
}
373-
}
374-
}
375-
376-
private async void KeepAliveProbe(HttpClient client_, CancellationToken ct)
377-
{
378-
// Send "HEAD / HTTP/2" request.
379-
var request = new System.Net.Http.HttpRequestMessage();
380-
request.Method = new System.Net.Http.HttpMethod("HEAD");
381-
request.RequestUri = new System.Uri(this.BaseUrl, System.UriKind.RelativeOrAbsolute);
382-
request.Version = System.Net.HttpVersion.Version20;
383-
384-
var keepaliveFailureCnt = 0;
385-
try {
386-
await client_.SendAsync(request, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, ct).ConfigureAwait(false);
387-
} catch (Exception e) {
388-
keepaliveFailureCnt++;
389-
// KEEP_ALIVE_RETRIES may be too big here (16) for the interval of 3 minutes
390-
if ( keepaliveFailureCnt < HttpClientFactory.KEEP_ALIVE_RETRIES ) {
391-
Logger.Warning("KeepAliveProbe failed to send request: " + e.Message);
392-
} else {
393-
Logger.Error("KeepAliveProbe failed to send request: " + e.Message);
394-
Logger.Error("KeepAliveProbe retry exceeded max. Throwing");
395-
throw e;
396-
}
397-
}
398-
}
399335

400336
public static void AddExtraHeaders(HttpRequestMessage request)
401337
{
@@ -959,13 +895,6 @@ public bool EnableLibrary(string srcName)
959895
return RunAction(action) != null;
960896
}
961897

962-
public bool CloseDatabase()
963-
{
964-
var action = new ModifyWorkspaceAction();
965-
action.Close_database = conn.DbName;
966-
return RunAction(action, isReadOnly: true) != null;
967-
}
968-
969898
public ICollection<Relation> Cardinality(string relName = null)
970899
{
971900
var action = new CardinalityAction();

RelationalAI/RelationalAI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>1.2.5</Version>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<Version>1.2.6</Version>
5+
<TargetFramework>net5.0</TargetFramework>
66
<PackageId>RelationalAI</PackageId>
77
<Authors>RelationalAI</Authors>
88
<Company>RelationalAI</Company>

RelationalAISamples/LocalWorkflow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def jaccard_similarity(a,b,v) = (count[x : tmp(a,b,x)] / count[x: (uedge(a, x) o
5656
);
5757

5858
Console.WriteLine("==> Jaccard Similarity: " + JObject.FromObject(queryResult).ToString());
59-
conn.CloseDatabase();
59+
6060
}
6161
}
6262
}

RelationalAISamples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Getting started
66

7-
First we need to install `Dotnet core 3.1` [dotnet-core-3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1) available for Windows, Linux and OSX.
7+
First we need to install `Dotnet core 5.0` [dotnet-core-5.0](https://dotnet.microsoft.com/download/dotnet-core/5.0) available for Windows, Linux and OSX.
88

99
## Usage
1010
### Dependencies

0 commit comments

Comments
 (0)