Skip to content

Commit fc9e3ac

Browse files
authored
Merge pull request #596 from kbase/develop
Release 0.13.1
2 parents 10b2247 + f5fa6a6 commit fc9e3ac

24 files changed

+3514
-2442
lines changed

docshtml/Workspace.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docsource/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# The short X.Y version.
5353
version = '0.13'
5454
# The full version, including alpha/beta/rc tags.
55-
release = '0.13.0'
55+
release = '0.13.1'
5656

5757
# The language for content autogenerated by Sphinx. Refer to documentation
5858
# for a list of supported languages.

docsource/releasenotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
Workspace service release notes
44
===============================
55

6+
VERSION: 0.13.1 (Released 4/27/2022)
7+
------------------------------------
8+
9+
UPDATES:
10+
11+
* ``save_objects`` will no longer throw an error if an empty ``ProvenanceAction`` is included in
12+
the call. Rather, empty ``ProvenanceAction`` instances will be silently omitted from the list.
13+
614
VERSION: 0.13.0 (Released 4/13/2022)
715
------------------------------------
816

lib/Bio/KBase/workspace/Client.pm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9556,8 +9556,11 @@ A provenance action.
95569556
A provenance action (PA) is an action taken while transforming one data
95579557
object to another. There may be several PAs taken in series. A PA is
95589558
typically running a script, running an api command, etc. All of the
9559-
following fields are optional but at least one field must be present.
9560-
Furthermore, more information provided equates to better data provenance.
9559+
following fields are optional, but more information provided equates to
9560+
better data provenance.
9561+
9562+
If a provenance action has no fields defined at all, it is silently dropped from
9563+
the list.
95619564
95629565
resolved_ws_objects should never be set by the user; it is set by the
95639566
workspace service when returning data.

lib/biokbase/workspace/client.py

Lines changed: 292 additions & 288 deletions
Large diffs are not rendered by default.

src/us/kbase/workspace/ProvenanceAction.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
* A provenance action (PA) is an action taken while transforming one data
2121
* object to another. There may be several PAs taken in series. A PA is
2222
* typically running a script, running an api command, etc. All of the
23-
* following fields are optional but at least one field must be present.
24-
* Furthermore, more information provided equates to better data provenance.
23+
* following fields are optional, but more information provided equates to
24+
* better data provenance.
25+
*
26+
* If a provenance action has no fields defined at all, it is silently dropped from
27+
* the list.
2528
*
2629
* resolved_ws_objects should never be set by the user; it is set by the
2730
* workspace service when returning data.

src/us/kbase/workspace/WorkspaceServer.java

Lines changed: 23 additions & 186 deletions
Large diffs are not rendered by default.

src/us/kbase/workspace/database/provenance/ProvenanceAction.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,11 @@ private List<String> processReferences(
701701
}
702702
}
703703

704-
/** Build the {@link ProvenanceAction}. At least one field must be set before the build
705-
* attempt.
706-
* @return the provenance action.
704+
/** Check the builder has any fields set.
705+
* @return true if no fields are set, false otherwise.
707706
*/
708-
public ProvenanceAction build() {
709-
if ( // ew
707+
public boolean isEmpty() {
708+
return
710709
time == null &&
711710
caller == null &&
712711
service == null &&
@@ -723,7 +722,15 @@ public ProvenanceAction build() {
723722
externalData == null &&
724723
subActions == null &&
725724
custom == null &&
726-
description == null) {
725+
description == null;
726+
}
727+
728+
/** Build the {@link ProvenanceAction}. At least one field must be set before the build
729+
* attempt.
730+
* @return the provenance action.
731+
*/
732+
public ProvenanceAction build() {
733+
if (isEmpty()) {
727734
throw new IllegalArgumentException(
728735
"At least one field in a provenance action must be provided");
729736
}

src/us/kbase/workspace/kbase/ArgUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static Provenance processProvenance(
118118
checkAddlArgs(a.getAdditionalProperties(), a.getClass());
119119
final Instant d = chooseInstant(a.getTime(), a.getEpoch(),
120120
"Cannot specify both time and epoch in provenance action");
121-
p.withAction(ProvenanceAction.getBuilder()
121+
final ProvenanceAction.Builder pa = ProvenanceAction.getBuilder()
122122
.withTime(d)
123123
.withCaller(a.getCaller())
124124
.withServiceName(a.getService())
@@ -135,9 +135,10 @@ public static Provenance processProvenance(
135135
.withExternalData(processExternalData(a.getExternalData()))
136136
.withSubActions(processSubActions(a.getSubactions()))
137137
.withCustom(a.getCustom())
138-
.withDescription(a.getDescription())
139-
.build()
140-
);
138+
.withDescription(a.getDescription());
139+
if (!pa.isEmpty()) { // requiring non-empty PAs broke external code unfortunately
140+
p.withAction(pa.build());
141+
}
141142
} catch (IllegalArgumentException | NullPointerException e) {
142143
throw new IllegalArgumentException(String.format("Provenance action #%s: %s",
143144
li.nextIndex(), e.getLocalizedMessage()), e);

src/us/kbase/workspace/kbase/InitWorkspaceServer.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@
5656
import us.kbase.workspace.database.mongo.exceptions.BlobStoreCommunicationException;
5757
import us.kbase.workspace.kbase.KBaseWorkspaceConfig.ListenerConfig;
5858
import us.kbase.workspace.kbase.BytestreamIdHandlerFactory.BytestreamClientCloner;
59+
import us.kbase.workspace.kbase.admin.AdministrationCommandSetInstaller;
5960
import us.kbase.workspace.kbase.admin.AdministratorHandler;
6061
import us.kbase.workspace.kbase.admin.AdministratorHandlerException;
6162
import us.kbase.workspace.kbase.admin.DefaultAdminHandler;
6263
import us.kbase.workspace.kbase.admin.KBaseAuth2AdminHandler;
6364
import us.kbase.workspace.kbase.admin.WorkspaceAdministration;
65+
import us.kbase.workspace.kbase.admin.WorkspaceAdministration.UserValidator;
6466
import us.kbase.workspace.listener.ListenerInitializationException;
6567
import us.kbase.workspace.listener.WorkspaceEventListener;
6668
import us.kbase.workspace.listener.WorkspaceEventListenerFactory;
@@ -78,9 +80,6 @@ public class InitWorkspaceServer {
7880

7981
public static final String COL_S3_OBJECTS = "s3_objects";
8082

81-
private static final int ADMIN_CACHE_MAX_SIZE = 100; // seems like more than enough admins
82-
private static final int ADMIN_CACHE_EXP_TIME_MS = 5 * 60 * 1000; // cache admin role for 5m
83-
8483
private static int maxUniqueIdCountPerCall = 100000;
8584

8685
private static int instanceCount = 0;
@@ -105,27 +104,20 @@ public boolean isFailed() {
105104
}
106105

107106
public static class WorkspaceInitResults {
108-
private final Workspace ws;
109107
private final WorkspaceServerMethods wsmeth;
110108
private final WorkspaceAdministration wsadmin;
111-
private final Types types;
109+
private final TypeServerMethods types;
112110

113111
public WorkspaceInitResults(
114-
final Workspace ws,
115112
final WorkspaceServerMethods wsmeth,
116113
final WorkspaceAdministration wsadmin,
117-
final Types types) {
114+
final TypeServerMethods types) {
118115
super();
119-
this.ws = ws;
120116
this.wsmeth = wsmeth;
121117
this.wsadmin = wsadmin;
122118
this.types = types;
123119
}
124120

125-
public Workspace getWs() {
126-
return ws;
127-
}
128-
129121
public WorkspaceServerMethods getWsmeth() {
130122
return wsmeth;
131123
}
@@ -134,7 +126,7 @@ public WorkspaceAdministration getWsAdmin() {
134126
return wsadmin;
135127
}
136128

137-
public Types getTypes() {
129+
public TypeServerMethods getTypes() {
138130
return types;
139131
}
140132
}
@@ -189,23 +181,25 @@ public static WorkspaceInitResults initWorkspaceServer(
189181
return null;
190182
}
191183
rep.reportInfo(String.format("Initialized %s backend", cfg.getBackendType().name()));
192-
final Types types = new Types(wsdeps.typeDB);
184+
// TODO CODE maybe merge these 2 classes?
185+
final LocalTypeServerMethods types = new LocalTypeServerMethods(new Types(wsdeps.typeDB));
193186
final IdReferenceHandlerSetFactoryBuilder builder = IdReferenceHandlerSetFactoryBuilder
194187
.getBuilder(maxUniqueIdCountPerCall)
195188
.withFactory(new HandleIdHandlerFactory(hsc))
196189
.withFactory(wsdeps.shockFac)
197190
.withFactory(wsdeps.sampleFac)
198191
.build();
199-
WorkspaceServerMethods wsmeth = new WorkspaceServerMethods(ws, types, builder, auth);
200-
WorkspaceAdministration wsadmin = new WorkspaceAdministration(
201-
ws, wsmeth, types, ah, ADMIN_CACHE_MAX_SIZE, ADMIN_CACHE_EXP_TIME_MS);
192+
final WorkspaceServerMethods wsmeth = new WorkspaceServerMethods(ws, builder, auth);
193+
final UserValidator userVal = (user, token) -> wsmeth.validateUser(user, token);
194+
final WorkspaceAdministration wsadmin = AdministrationCommandSetInstaller.install(
195+
WorkspaceAdministration.getBuilder(ah, userVal), wsmeth, types).build();
202196
final String mem = String.format(
203197
"Started workspace server instance %s. Free mem: %s Total mem: %s, Max mem: %s",
204198
++instanceCount, Runtime.getRuntime().freeMemory(),
205199
Runtime.getRuntime().totalMemory(),
206200
Runtime.getRuntime().maxMemory());
207201
rep.reportInfo(mem);
208-
return new WorkspaceInitResults(ws, wsmeth, wsadmin, types);
202+
return new WorkspaceInitResults(wsmeth, wsadmin, types);
209203
}
210204

211205
private static AdministratorHandler getAdminHandler(

0 commit comments

Comments
 (0)