Skip to content

Commit

Permalink
Fix response for 1.5.4 (#2369)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-yuen committed Apr 10, 2019
1 parent 3c3d34a commit dede706
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 15 deletions.
13 changes: 3 additions & 10 deletions dockstore-common/src/main/java/io/dockstore/common/PipHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
public final class PipHelper {
public static final String DEV_SEM_VER = "development-build";

private PipHelper() { }

/**
Expand All @@ -24,18 +25,10 @@ private PipHelper() { }
*/
public static String convertSemVerToAvailableVersion(String semVerString) {
if (semVerString == null || DEV_SEM_VER.equals(semVerString)) {
semVerString = "9001.9001.9001";
}
Version semVer = Version.valueOf(semVerString);
// Use the 1.6.0 even for snapshot
if (semVer.greaterThan(Version.valueOf("1.5.0"))) {
return "1.6.0";
}
if (semVer.greaterThan(Version.valueOf("1.4.0"))) {
return "1.5.0";
} else {
return "1.4.0";
}
Version semVer = Version.valueOf(semVerString);
return "1." + semVer.getMinorVersion() + ".0";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.*;

/**
* @author gluu
* @since 14/08/18
*/
public class PipHelperTest {
@Test
public void convertSemVerToAvailableVersion() throws Exception {
public void convertSemVerToAvailableVersion() {
Assert.assertEquals("1.7.0", PipHelper.convertSemVerToAvailableVersion("1.7.0-snapshot"));
Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.4"));
// TODO: expect 1.7.0 on develop
Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion(PipHelper.DEV_SEM_VER));
Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion(null));
Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.0-snapshot"));
Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.0"));
Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.4"));
Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.0-snapshot"));
Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.0"));
Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.4.0-snapshot"));
Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.4.0"));
Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.3.0-snapshot"));
Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.3.0"));
Assert.assertEquals("1.3.0", PipHelper.convertSemVerToAvailableVersion("1.3.0-snapshot"));
Assert.assertEquals("1.3.0", PipHelper.convertSemVerToAvailableVersion("1.3.0"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2019 OICR
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.dockstore.client.cli;

import io.swagger.client.ApiClient;
import io.swagger.client.api.MetadataApi;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.rules.ExpectedException;

public class MetadataIT extends BaseIT {
@Rule
public final SystemOutRule systemOutRule = new SystemOutRule().enableLog().muteForSuccessfulTests();

@Rule
public final SystemErrRule systemErrRule = new SystemErrRule().enableLog().muteForSuccessfulTests();

@Rule
public final ExpectedSystemExit systemExit = ExpectedSystemExit.none();

@Rule
public ExpectedException thrown= ExpectedException.none();




@Test
public void testRunnerDependencies() {
ApiClient apiClient = getWebClient();
MetadataApi metadataApi = new MetadataApi(apiClient);
String runnerDependencies = metadataApi.getRunnerDependencies("1.5.4", "2", "cwltool", "text");
Assert.assertTrue(runnerDependencies.contains("cwltool==1.0.20180403145700"));
runnerDependencies = metadataApi.getRunnerDependencies("1.6.0", "2", "cwltool", "text");
Assert.assertTrue(runnerDependencies.contains("cwltool==1.0.20181217162649"));
runnerDependencies = metadataApi.getRunnerDependencies("1.6.4", "2", "cwltool", "text");
Assert.assertTrue(runnerDependencies.contains("cwltool==1.0.20181217162649"));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ public Response getRunnerDependencies(
}
boolean unwrap = !("json").equals(output);
String fileVersion = PipHelper.convertSemVerToAvailableVersion(clientVersion);
if (fileVersion == null) {
throw new CustomWebApplicationException("Invalid version, could not retrieve runner dependencies file", HttpStatus.SC_BAD_REQUEST);
}
try {
String content = Resources.toString(this.getClass().getClassLoader()
.getResource("requirements/" + fileVersion + "/requirements" + (pythonVersion.startsWith("3") ? "3" : "") + ".txt"), StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setuptools==36.5.0
cwl-runner
cwltool==1.0.20170828135420
schema-salad==2.6.20170806163416
avro==1.8.1
ruamel.yaml==0.14.12
requests==2.18.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setuptools==36.5.0
cwl-runner
cwltool==1.0.20170828135420
schema-salad==2.6.20170806163416
avro-cwl==1.8.3
ruamel.yaml==0.14.12
requests==2.18.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
bagit==1.7.0
CacheControl==0.11.7
certifi==2019.3.9
chardet==3.0.4
cwltool==1.0.20181217162649
decorator==4.4.0
idna==2.8
isodate==0.6.0
lockfile==0.12.2
lxml==4.3.3
mistune==0.8.4
mypy-extensions==0.4.1
networkx==2.2
pathlib2==2.3.2
pkg-resources==0.0.0
prov==1.5.1
psutil==5.6.1
pyparsing==2.4.0
python-dateutil==2.8.0
rdflib==4.2.2
rdflib-jsonld==0.4.0
requests==2.21.0
ruamel.ordereddict==0.4.13
ruamel.yaml==0.15.77
scandir==1.10.0
schema-salad==3.0.20181206233650
shellescape==3.4.1
six==1.12.0
subprocess32==3.5.3
typing==3.6.6
typing-extensions==3.7.2
urllib3==1.24.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
bagit==1.7.0
CacheControl==0.11.7
certifi==2019.3.9
chardet==3.0.4
cwltool==1.0.20181217162649
decorator==4.4.0
idna==2.8
isodate==0.6.0
lockfile==0.12.2
lxml==4.3.3
mistune==0.8.4
mypy-extensions==0.4.1
networkx==2.2
pkg-resources==0.0.0
prov==1.5.1
psutil==5.6.1
pyparsing==2.4.0
python-dateutil==2.8.0
rdflib==4.2.2
rdflib-jsonld==0.4.0
requests==2.21.0
ruamel.yaml==0.15.77
scandir==1.10.0
schema-salad==3.0.20181206233650
shellescape==3.4.1
six==1.12.0
typing==3.6.6
typing-extensions==3.7.2
urllib3==1.24.1

0 comments on commit dede706

Please sign in to comment.