Skip to content

Commit

Permalink
Merge pull request #596 from kbase/develop
Browse files Browse the repository at this point in the history
Release 0.13.1
  • Loading branch information
MrCreosote authored Apr 27, 2022
2 parents 10b2247 + f5fa6a6 commit fc9e3ac
Show file tree
Hide file tree
Showing 24 changed files with 3,514 additions and 2,442 deletions.
2 changes: 1 addition & 1 deletion docshtml/Workspace.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docsource/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# The short X.Y version.
version = '0.13'
# The full version, including alpha/beta/rc tags.
release = '0.13.0'
release = '0.13.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
8 changes: 8 additions & 0 deletions docsource/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Workspace service release notes
===============================

VERSION: 0.13.1 (Released 4/27/2022)
------------------------------------

UPDATES:

* ``save_objects`` will no longer throw an error if an empty ``ProvenanceAction`` is included in
the call. Rather, empty ``ProvenanceAction`` instances will be silently omitted from the list.

VERSION: 0.13.0 (Released 4/13/2022)
------------------------------------

Expand Down
7 changes: 5 additions & 2 deletions lib/Bio/KBase/workspace/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9556,8 +9556,11 @@ A provenance action.
A provenance action (PA) is an action taken while transforming one data
object to another. There may be several PAs taken in series. A PA is
typically running a script, running an api command, etc. All of the
following fields are optional but at least one field must be present.
Furthermore, more information provided equates to better data provenance.
following fields are optional, but more information provided equates to
better data provenance.
If a provenance action has no fields defined at all, it is silently dropped from
the list.
resolved_ws_objects should never be set by the user; it is set by the
workspace service when returning data.
Expand Down
580 changes: 292 additions & 288 deletions lib/biokbase/workspace/client.py

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/us/kbase/workspace/ProvenanceAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
* A provenance action (PA) is an action taken while transforming one data
* object to another. There may be several PAs taken in series. A PA is
* typically running a script, running an api command, etc. All of the
* following fields are optional but at least one field must be present.
* Furthermore, more information provided equates to better data provenance.
* following fields are optional, but more information provided equates to
* better data provenance.
*
* If a provenance action has no fields defined at all, it is silently dropped from
* the list.
*
* resolved_ws_objects should never be set by the user; it is set by the
* workspace service when returning data.
Expand Down
209 changes: 23 additions & 186 deletions src/us/kbase/workspace/WorkspaceServer.java

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions src/us/kbase/workspace/database/provenance/ProvenanceAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,11 @@ private List<String> processReferences(
}
}

/** Build the {@link ProvenanceAction}. At least one field must be set before the build
* attempt.
* @return the provenance action.
/** Check the builder has any fields set.
* @return true if no fields are set, false otherwise.
*/
public ProvenanceAction build() {
if ( // ew
public boolean isEmpty() {
return
time == null &&
caller == null &&
service == null &&
Expand All @@ -723,7 +722,15 @@ public ProvenanceAction build() {
externalData == null &&
subActions == null &&
custom == null &&
description == null) {
description == null;
}

/** Build the {@link ProvenanceAction}. At least one field must be set before the build
* attempt.
* @return the provenance action.
*/
public ProvenanceAction build() {
if (isEmpty()) {
throw new IllegalArgumentException(
"At least one field in a provenance action must be provided");
}
Expand Down
9 changes: 5 additions & 4 deletions src/us/kbase/workspace/kbase/ArgUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static Provenance processProvenance(
checkAddlArgs(a.getAdditionalProperties(), a.getClass());
final Instant d = chooseInstant(a.getTime(), a.getEpoch(),
"Cannot specify both time and epoch in provenance action");
p.withAction(ProvenanceAction.getBuilder()
final ProvenanceAction.Builder pa = ProvenanceAction.getBuilder()
.withTime(d)
.withCaller(a.getCaller())
.withServiceName(a.getService())
Expand All @@ -135,9 +135,10 @@ public static Provenance processProvenance(
.withExternalData(processExternalData(a.getExternalData()))
.withSubActions(processSubActions(a.getSubactions()))
.withCustom(a.getCustom())
.withDescription(a.getDescription())
.build()
);
.withDescription(a.getDescription());
if (!pa.isEmpty()) { // requiring non-empty PAs broke external code unfortunately
p.withAction(pa.build());
}
} catch (IllegalArgumentException | NullPointerException e) {
throw new IllegalArgumentException(String.format("Provenance action #%s: %s",
li.nextIndex(), e.getLocalizedMessage()), e);
Expand Down
30 changes: 12 additions & 18 deletions src/us/kbase/workspace/kbase/InitWorkspaceServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@
import us.kbase.workspace.database.mongo.exceptions.BlobStoreCommunicationException;
import us.kbase.workspace.kbase.KBaseWorkspaceConfig.ListenerConfig;
import us.kbase.workspace.kbase.BytestreamIdHandlerFactory.BytestreamClientCloner;
import us.kbase.workspace.kbase.admin.AdministrationCommandSetInstaller;
import us.kbase.workspace.kbase.admin.AdministratorHandler;
import us.kbase.workspace.kbase.admin.AdministratorHandlerException;
import us.kbase.workspace.kbase.admin.DefaultAdminHandler;
import us.kbase.workspace.kbase.admin.KBaseAuth2AdminHandler;
import us.kbase.workspace.kbase.admin.WorkspaceAdministration;
import us.kbase.workspace.kbase.admin.WorkspaceAdministration.UserValidator;
import us.kbase.workspace.listener.ListenerInitializationException;
import us.kbase.workspace.listener.WorkspaceEventListener;
import us.kbase.workspace.listener.WorkspaceEventListenerFactory;
Expand All @@ -78,9 +80,6 @@ public class InitWorkspaceServer {

public static final String COL_S3_OBJECTS = "s3_objects";

private static final int ADMIN_CACHE_MAX_SIZE = 100; // seems like more than enough admins
private static final int ADMIN_CACHE_EXP_TIME_MS = 5 * 60 * 1000; // cache admin role for 5m

private static int maxUniqueIdCountPerCall = 100000;

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

public static class WorkspaceInitResults {
private final Workspace ws;
private final WorkspaceServerMethods wsmeth;
private final WorkspaceAdministration wsadmin;
private final Types types;
private final TypeServerMethods types;

public WorkspaceInitResults(
final Workspace ws,
final WorkspaceServerMethods wsmeth,
final WorkspaceAdministration wsadmin,
final Types types) {
final TypeServerMethods types) {
super();
this.ws = ws;
this.wsmeth = wsmeth;
this.wsadmin = wsadmin;
this.types = types;
}

public Workspace getWs() {
return ws;
}

public WorkspaceServerMethods getWsmeth() {
return wsmeth;
}
Expand All @@ -134,7 +126,7 @@ public WorkspaceAdministration getWsAdmin() {
return wsadmin;
}

public Types getTypes() {
public TypeServerMethods getTypes() {
return types;
}
}
Expand Down Expand Up @@ -189,23 +181,25 @@ public static WorkspaceInitResults initWorkspaceServer(
return null;
}
rep.reportInfo(String.format("Initialized %s backend", cfg.getBackendType().name()));
final Types types = new Types(wsdeps.typeDB);
// TODO CODE maybe merge these 2 classes?
final LocalTypeServerMethods types = new LocalTypeServerMethods(new Types(wsdeps.typeDB));
final IdReferenceHandlerSetFactoryBuilder builder = IdReferenceHandlerSetFactoryBuilder
.getBuilder(maxUniqueIdCountPerCall)
.withFactory(new HandleIdHandlerFactory(hsc))
.withFactory(wsdeps.shockFac)
.withFactory(wsdeps.sampleFac)
.build();
WorkspaceServerMethods wsmeth = new WorkspaceServerMethods(ws, types, builder, auth);
WorkspaceAdministration wsadmin = new WorkspaceAdministration(
ws, wsmeth, types, ah, ADMIN_CACHE_MAX_SIZE, ADMIN_CACHE_EXP_TIME_MS);
final WorkspaceServerMethods wsmeth = new WorkspaceServerMethods(ws, builder, auth);
final UserValidator userVal = (user, token) -> wsmeth.validateUser(user, token);
final WorkspaceAdministration wsadmin = AdministrationCommandSetInstaller.install(
WorkspaceAdministration.getBuilder(ah, userVal), wsmeth, types).build();
final String mem = String.format(
"Started workspace server instance %s. Free mem: %s Total mem: %s, Max mem: %s",
++instanceCount, Runtime.getRuntime().freeMemory(),
Runtime.getRuntime().totalMemory(),
Runtime.getRuntime().maxMemory());
rep.reportInfo(mem);
return new WorkspaceInitResults(ws, wsmeth, wsadmin, types);
return new WorkspaceInitResults(wsmeth, wsadmin, types);
}

private static AdministratorHandler getAdminHandler(
Expand Down
Loading

0 comments on commit fc9e3ac

Please sign in to comment.