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

DO NOT MERGE: .Net SDK to pull & send models #2514

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .gitguardian.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
secret:
ignored-paths:
ignored_paths:
- 'packages/server/modules/emails/tests'
ignored-matches:
ignored_matches:
- match: acd87c5a50b56df91a795e999812a3a4
name: 'packages/frontend/src/bootstrapper.ts - mixpanel token'
- match: c7bf45ffe02afaae52c8e37cdb1ae33165370be3b44a5da43e8cba43c7da5f33
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ minio-data/
postgres-data/
redis-data/

.tshy-build
.tshy-build

# .Net
**/bin/**
**/obj/**
30 changes: 30 additions & 0 deletions speckle-server.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{D48C46C3-C708-459B-BA56-27D3E0D9C6EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "large-models-sender", "utils\large-models-sender\large-models-sender.csproj", "{D22F08F9-8A12-419E-9746-F981EEC27B70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D22F08F9-8A12-419E-9746-F981EEC27B70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D22F08F9-8A12-419E-9746-F981EEC27B70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D22F08F9-8A12-419E-9746-F981EEC27B70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D22F08F9-8A12-419E-9746-F981EEC27B70}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D22F08F9-8A12-419E-9746-F981EEC27B70} = {D48C46C3-C708-459B-BA56-27D3E0D9C6EA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {894B4C00-8968-4C3D-8DDC-24398CF38601}
EndGlobalSection
EndGlobal
80 changes: 80 additions & 0 deletions utils/large-models-sender/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System.Diagnostics;
using Objects.BuiltElements;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Transports;

var sourceServer = "https://latest.speckle.systems";
var sourceToken = "";
var targetServer = "https://testing3.speckle.dev";
var targetToken = "";

var sourceAccount = new Account
{
token = sourceToken,
serverInfo = new ServerInfo { url = sourceServer }
};
var sourceProjectId = "ecb4a794dd";
var sourceVersionId = "0bd6f92a13";
var receiveTransport = new ServerTransport(
sourceAccount,
sourceProjectId,
6000 //timeout
);

var sourceClient = new Client(sourceAccount);
var sourceVersion = await sourceClient.CommitGet(sourceProjectId, sourceVersionId);
var sourceObjectId = sourceVersion.referencedObject;

var retrievedObject = await Operations.Receive(sourceObjectId, receiveTransport).ConfigureAwait(false);

Console.WriteLine($"Successfully retrieved an object with ID: '{retrievedObject.id}'");

var targetAccount = new Account
{
token = targetToken,
serverInfo = new ServerInfo { url = targetServer }
};
var targetClient = new Client(targetAccount);

var now = DateTime.Now;
var targetProjectId = await targetClient
.StreamCreate(new StreamCreateInput { name = $"test @ {now}" })
.ConfigureAwait(false);

if (targetProjectId is null)
{
throw new Exception("failed to create project");
}

var targetServerTransport = new ServerTransport(targetAccount, targetProjectId, 6000);

var stopwatch = new Stopwatch();
stopwatch.Start();
var objId = await Operations.Send(retrievedObject, new[] { targetServerTransport }).ConfigureAwait(false);
stopwatch.Stop();
Console.WriteLine($"Sending the object to the target server took {stopwatch.ElapsedMilliseconds}");

var targetBranchName = $"test branch @ {now}";
var branch = await targetClient.BranchCreate(new BranchCreateInput {
streamId = targetProjectId,
name = targetBranchName
});
if (branch is null) {
throw new Exception("Failed to create branch.");
}

var commit = await targetClient.CommitCreate(
new CommitCreateInput
{
streamId = targetProjectId,
branchName = targetBranchName,
objectId = objId,
message = "A large test commit"
});
if (commit is null) {
throw new Exception("Failed to create commit.");
}

sourceClient.Dispose();
targetClient.Dispose();
16 changes: 16 additions & 0 deletions utils/large-models-sender/large-models-sender.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>large_models_sender</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Speckle.Core" Version="2.19.2" />
<PackageReference Include="Speckle.Objects" Version="2.19.2" />
</ItemGroup>

</Project>