Skip to content
Open
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
11 changes: 1 addition & 10 deletions BaseSpace.SDK.sln
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseSpace.SDK", "BaseSpace.SDK\BaseSpace.SDK.csproj", "{53207AEA-0E50-45AB-9AA5-D460CD3844BB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{455352A5-C36E-4341-AD1F-935800684CC9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseSpace.SDK.Tests", "BaseSpace.SDK.Tests\BaseSpace.SDK.Tests.csproj", "{FC73DFAB-7F44-4D55-91FC-339C968E1298}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget (2)", ".nuget (2)", "{E6DCBAD8-85F3-477E-B14C-084952A5F624}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
15 changes: 4 additions & 11 deletions BaseSpace.SDK/BaseSpace.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<HintPath>..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Illumina.TerminalVelocity">
<HintPath>..\packages\TerminalVelocity.Sharp.1.0.0.72\lib\net40\Illumina.TerminalVelocity.dll</HintPath>
<HintPath>..\..\BrightSpark\output\bin\Illumina.TerminalVelocity.dll</HintPath>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you get rid of this change?

</Reference>
<Reference Include="ServiceStack.Common, Version=3.9.71.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -98,6 +98,7 @@
<Compile Include="Interfaces\IRequest.cs" />
<Compile Include="Interfaces\IRequestOptions.cs" />
<Compile Include="Interfaces\IWebClient.cs" />
<Compile Include="ServiceModels\Request\CreateProjectShareRequest.cs" />
<Compile Include="ServiceModels\Request\ListLibraryContainersRequest.cs" />
<Compile Include="ServiceModels\Request\ListSampleLibrariesFromRunRequest.cs" />
<Compile Include="ServiceModels\Request\AbstractRequest.cs" />
Expand Down Expand Up @@ -179,6 +180,7 @@
<Compile Include="ServiceModels\Response\ListSampleLibrariesResponse.cs" />
<Compile Include="ServiceModels\Response\ListSupportedLibraryPrepKitsResponse.cs" />
<Compile Include="ServiceModels\Response\PlannedRunReadyResponse.cs" />
<Compile Include="ServiceModels\Response\ProjectShareResponse.cs" />
<Compile Include="ServiceModels\Response\SearchResponse.cs" />
<Compile Include="ServiceModels\Response\SetPropertiesResponse.cs" />
<Compile Include="ServiceModels\Response\CreateAppSessionLogsResponse.cs" />
Expand Down Expand Up @@ -228,6 +230,7 @@
<Compile Include="Types\Agreement.cs" />
<Compile Include="Types\ApiCategoryAttribute.cs" />
<Compile Include="Types\ApiMeta.cs" />
<Compile Include="Types\Invite.cs" />
<Compile Include="Types\PlannedRun.cs" />
<Compile Include="Types\SourceLibrary.cs" />
<Compile Include="Types\PropertyContentMap.cs" />
Expand Down Expand Up @@ -264,17 +267,7 @@
<Compile Include="Types\Variant.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here please remove changes to the nuget

<Compile Include="Types\VerificationCode.cs" />
</ItemGroup>
<ItemGroup>
<None Include="BaseSpace.SDK.nuspec">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!--<Import Project="$(SolutionDir)\.nuget\nuget.targets" />-->
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
2 changes: 1 addition & 1 deletion BaseSpace.SDK/BaseSpace.SDK.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<language>en-US</language>
<copyright>illumina 2013 and contributors</copyright>
<dependencies>
<dependency id="TerminalVelocity.Sharp"/>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please remove this change too?

</dependencies>
</metadata>
<files>
Expand Down
4 changes: 4 additions & 0 deletions BaseSpace.SDK/BaseSpaceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public CreateProjectResponse CreateProject(CreateProjectRequest request, IReques
{
return WebClient.Send(request, options);
}
public ProjectShareResponse CreateProjectShare(CreateProjectShareRequest request, IRequestOptions options = null)
{
return WebClient.Send(request, options);
}
#endregion

#region AppSessions
Expand Down
1 change: 1 addition & 0 deletions BaseSpace.SDK/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class PropertyTypes
public const string SAMPLE_FILE = "samplefile";
public const string APPRESULT_FILE = "appresultfile";
public const string APPSESSION = "appsession";
public const string INVITE = "invite";
public const string MAP = "map";
public const string LIST_SUFFIX = "[]";
}
Expand Down
75 changes: 45 additions & 30 deletions BaseSpace.SDK/Infrastructure/FileUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ public class FileUpload
protected IClientSettings ClientSettings { get; set; }
protected IRequestOptions Options { get; set; }
protected ILog Logger = LogManager.GetCurrentClassLogger();

public FileUpload(IWebClient webClient, IClientSettings settings, IRequestOptions options)
{
WebClient = webClient;
ClientSettings = settings;
Options = options;
}

public virtual TResult UploadFile<TResult>(FileUploadRequestBase<TResult> request)
where TResult : FileResponse
{
Logger.DebugFormat("numthreads {0}", request.ThreadCount);
TResult file = null;
public virtual TResult UploadFile<TResult>(FileUploadRequestBase<TResult> request)
where TResult : FileResponse
{
Logger.DebugFormat("numthreads {0}", request.ThreadCount);
TResult file = null;

RetryLogic.DoWithRetry(ClientSettings.RetryAttempts, string.Format("Uploading file {0}", request.FileInfo.Name),
() =>
{
{
request.MultiPart = request.FileInfo.Length >= ClientSettings.FileUploadMultipartSizeThreshold;

file = request.MultiPart.Value ?
UploadFile_MultiPart(request) :
WebClient.Send(request);
WebClient.Send(request);
}, Logger, retryHandler:
(exc) =>
{
Expand All @@ -59,14 +59,14 @@ public virtual TResult UploadFile<TResult>(FileUploadRequestBase<TResult> reques
return file;
}

protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TResult> request)
where TResult : FileResponse
protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TResult> request)
where TResult : FileResponse
{
Logger.InfoFormat("File Upload: {0}: Initiating multipart upload", request.FileInfo.Name);

var fileUploadresp = WebClient.Send(request);
var fileUploadresp = WebClient.Send(request);

var server = ClientSettings.BaseSpaceApiUrl.TrimEnd('/');
var server = ClientSettings.BaseSpaceApiUrl.TrimEnd('/');

uint chunkSize = ClientSettings.FileUploadMultipartChunkSize;

Expand Down Expand Up @@ -125,7 +125,7 @@ protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TR
}));

bool success = errorSignal.WaitOne(0) == false;

var status = success ? FileUploadStatus.complete : FileUploadStatus.aborted;

var statusReq = new FileRequestPost<TResult>
Expand All @@ -143,7 +143,7 @@ protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TR


static object _syncRead = new object();

protected virtual void UploadPart(string fullUrl, FileInfo fileToUpload, long startPosition, int partNumber, ManualResetEvent errorSignal, string partDescription, uint chunkSize)
{
RetryLogic.DoWithRetry(ClientSettings.RetryAttempts, string.Format("Uploading part {0} of {1}", partDescription, fileToUpload.Name),
Expand All @@ -159,9 +159,9 @@ protected virtual void UploadPart(string fullUrl, FileInfo fileToUpload, long st
{
data = BufferPool.GetChunk((int)chunkSize);

var authentication = ClientSettings.Authentication;
authentication.UpdateHttpHeader(wc.Headers, new Uri(fullUrl), "PUT");
var authentication = ClientSettings.Authentication;
authentication.UpdateHttpHeader(wc.Headers, new Uri(fullUrl), "PUT");

int actualSize;
int desiredSize = (int)Math.Min(fileToUpload.Length - startPosition, chunkSize);
lock (_syncRead) // avoid thrashing the disk
Expand Down Expand Up @@ -196,18 +196,33 @@ public static int NumFileUploadParts(FileInfo file)
}

private class BSWebClient : WebClient
{
//TODO: Doesnt seem right? Need refactor?
// const int CONNECTION_LIMIT = 16;
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address) as HttpWebRequest;

if (request != null && request.ServicePoint.ConnectionLimit < 20)
request.ServicePoint.ConnectionLimit = 10000; //Note: Is this changing global value?

return request;
}
}
{
//TODO: Doesnt seem right? Need refactoring?
// const int CONNECTION_LIMIT = 16;
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address) as HttpWebRequest;

if (request != null && request.ServicePoint.ConnectionLimit < 20)
request.ServicePoint.ConnectionLimit = 10000; //Note: Is this changing global value?

// Workaround to support slow internet connections.
// On very slow internet connections (specifically between the client and the BaseSpace API server),
// multi-part file uploads tend to fail due to a request timeout.
if (request != null)
{
// Set the timeout to 10 min (vs default 100 sec).
// This setting was confirmed to work for the minimum upload part size of 5 MB
// on connections with sustainable upload speeds of 20 KB/s and higher.
// Technically, this timeout should be tied to the configured part size,
// but cursory tests demonstrated that for larger part sizes greater timeouts
// start inducing errors (500 in particular) on the server side.
request.Timeout = 600000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this change into a different pull request? I feel it is unrelated to sharing api

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request was not intended to be merged directly, just the ideas for
the change. We fixed our fork of the SDK (fixing the slow uploads from
Asia) in this manner, but there is probably a better way to fix it. I´m
juggling too many other things to be able to help.

On Fri, Apr 24, 2015 at 4:50 PM, adamnation [email protected]
wrote:

In BaseSpace.SDK/Infrastructure/FileUpload.cs
#39 (comment)
:

  •            if (request != null && request.ServicePoint.ConnectionLimit < 20)
    
  •                request.ServicePoint.ConnectionLimit = 10000;  //Note: Is this changing global value?
    
  •            // Workaround to support slow internet connections.
    
  •            // On very slow internet connections (specifically between the client and the BaseSpace API server),
    
  •            // multi-part file uploads tend to fail due to a request timeout.
    
  •            if (request != null)
    
  •            {
    
  •                // Set the timeout to 10 min (vs default 100 sec).
    
  •                // This setting was confirmed to work for the minimum upload part size of 5 MB
    
  •                // on connections with sustainable upload speeds of 20 KB/s and higher.
    
  •                // Technically, this timeout should be tied to the configured part size,
    
  •                // but cursory tests demonstrated that for larger part sizes greater timeouts
    
  •                // start inducing errors (500 in particular) on the server side.
    
  •                request.Timeout = 600000;
    

can you make this change into a different pull request? I feel it is
unrelated to sharing api


Reply to this email directly or view it on GitHub
https://github.com/basespace/basespace-csharp-sdk/pull/39/files#r29084624
.

request.ReadWriteTimeout = request.Timeout;
}

return request;
}
}
}
}
2 changes: 2 additions & 0 deletions BaseSpace.SDK/Interfaces/IBaseSpaceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public interface IBaseSpaceClient

ListAppSessionsResponse ListAppSessions(ListAppSessionsRequest request, IRequestOptions options = null);

ProjectShareResponse CreateProjectShare(CreateProjectShareRequest request, IRequestOptions options = null);

GetAppSessionResponse GetAppSession(GetAppSessionRequest request, IRequestOptions options = null);

CreateAppSessionLogsResponse CreateAppSessionLogs(CreateAppSessionLogsRequest request, IRequestOptions options = null);
Expand Down
73 changes: 73 additions & 0 deletions BaseSpace.SDK/ServiceModels/Request/CreateProjectShareRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Runtime.Serialization;

namespace Illumina.BaseSpace.SDK.ServiceModels
{
public enum SharePermissions
{
Read,
Write,
Own
}

[DataContract]
public class CreateProjectShareRequest : AbstractResourceRequest<ProjectShareResponse>
{
private const string ReadPermission = "READ";
private const string WritePermission = "WRITE";
private const string OwnerPermission = "OWN";

public CreateProjectShareRequest(string id, string email, string permission,
string description = "") : base(id)
{
if (permission != ReadPermission || permission != WritePermission || permission!=OwnerPermission)
throw new ArgumentException("Permission must be either READ, WRITE or OWN");
Permission = permission;
CommonConstruct(id, email, description);
}

public CreateProjectShareRequest(string id, string email, SharePermissions permission,
string description = "") : base(id)
{
CommonConstruct(id, email, description);
switch (permission)
{
case SharePermissions.Read:
Permission = ReadPermission;
break;
case SharePermissions.Write:
Permission = WritePermission;
break;
case SharePermissions.Own:
Permission = OwnerPermission;
break;
}
}

private void CommonConstruct(string id, string email, string description)
{
if (string.IsNullOrEmpty(id))
throw new ArgumentException("You must provide an id");
if (string.IsNullOrEmpty(email) || !email.Contains("@"))
throw new ArgumentException("You must provide an id");
if (description == null)
description = string.Empty;
Id = id;
Email = email;
Description = description;
HttpMethod = HttpMethods.POST;
}

[DataMember]
public string Email { get; set; }
[DataMember]
public string Permission { get; set; }
[DataMember]
public string Description { get; set; }

protected override string GetUrl()
{
return string.Format("{0}/project/{1}/invites", Version, Id);
}
}
}
9 changes: 9 additions & 0 deletions BaseSpace.SDK/ServiceModels/Response/ProjectShareResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Illumina.BaseSpace.SDK.Types;

namespace Illumina.BaseSpace.SDK.ServiceModels
{
public class ProjectShareResponse : ApiResponse<Invite>
{

}
}
59 changes: 59 additions & 0 deletions BaseSpace.SDK/Types/Invite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Runtime.Serialization;

namespace Illumina.BaseSpace.SDK.Types
{
[DataContract(Name = "Invite")]
public class InviteCompact : AbstractResource
{
[DataMember(IsRequired = true)]
public override string Id { get; set; }

[DataMember]
public override Uri Href { get; set; }

[DataMember]
public UserCompact UserInvited { get; set; }

[DataMember]
public string EmailInvited { get; set; }


public string Type
{
get { return PropertyTypes.INVITE; }
}
public override string ToString()
{
return string.Format("Href: {0}; Id: {1}", Href, Id);
}
}

[DataContract]
public class Invite : InviteCompact
{
[DataMember]
public Uri HrefInvite { get; set; }

[DataMember]
public string Status { get; set; }

[DataMember]
public DateTime DateCreated { get; set; }
[DataMember]
public DateTime DateModified { get; set; }

[DataMember]
public string Permission { get; set; }

[DataMember]
public bool HasCollaborators { get; set; }

[DataMember]
public IContentReference<IAbstractResource>[] References { get; set; }

[DataMember]
public long TotalSize { get; set; }
}

}