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

Java edits for kb-sdk 1.3 #350

Merged
merged 9 commits into from
Jun 19, 2020

Conversation

ialarmedalien
Copy link
Collaborator

@ialarmedalien ialarmedalien commented Jun 11, 2020

Some changes to prepare kb-sdk for generating GitHub actions and updating the default module builds.

The first commit is all whitespace changes -- my editor removes trailing whitespace and turns tabs into spaces, so I committed all the whitespace changes prior to the content changes. I would suggest viewing just the last three commits.

The changes in this PR comprise:

  • adding a build date stamp to kb-sdk version
  • cleaning up some commented-out lines in the Module Builder
  • added in some extra feedback to alert users as to whether auth is using an environment variable or an auth token in a file
  • added in a GitHub action that does some rudimentary checks of kb-sdk functioning, in lieu of having proper tests.

@@ -102,7 +102,7 @@
</target>



<tstamp/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Timestamp

@@ -116,7 +116,8 @@
<echo file="${src}/us/kbase/mobu/git.properties">### PLEASE DO NOT CHANGE THIS FILE MANUALLY! ###
giturl=${git.url}
branch=${git.branch}
commit=${git.commit}</echo>
commit=${git.commit}
build_timestamp=${DSTAMP}-${TSTAMP}</echo>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add date and time to the git.properties file

+ (gitCommit == null ? "" : (" (commit " + gitCommit + ")")));
}

public static String getBuildTimestamp() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Read the build timestamp from the git.properties file

String timestamp = getBuildTimestamp();
System.out.println("KBase SDK version " + VERSION
+ (timestamp == null ? "" : ("_" + timestamp))
+ (gitCommit == null ? "" : (" (commit " + gitCommit + ")")));
Copy link
Collaborator Author

@ialarmedalien ialarmedalien Jun 11, 2020

Choose a reason for hiding this comment

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

Include the build date and time with the kb-sdk version.

The version string now looks like this:
KBase SDK version 1.2.0_20200611-1439 (commit 7e58f55ad589fa64f83804c2dc9e380620210c45) (from GitHub Actions output)

@@ -169,19 +169,16 @@ public void initialize(boolean example) throws Exception {
}

switch(this.language) {
// Perl just needs an impl file and a start server script
// start_server scripts are generated by the Makefile
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

clean up comments and remove commented-out lines

false, // core or sync clients
false, // dynamic client
null, //tagVer
true, // async clients
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whitespace changes for nicer alignment

@@ -38,6 +38,11 @@ public ConfigLoader(Properties props, boolean testMode,
if (authUrl == null)
throw new IllegalStateException("Error: 'auth_service_url' parameter is not set in " +
configPathInfo);
endPoint = props.getProperty("kbase_endpoint");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved this check up so that kb-sdk will fail earlier if the kbase_endpoint property is not set

callbackUrl == null
? "http://fakecallbackurl"
: callbackUrl.toExternalForm()
).exec(tlDir).getExitCode();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whitespace changes only -- an upcoming PR has changes to this command and this reformatting makes them easier to understand.

Runtime.getRuntime().exec(cmd.cmdParts, null, workDir);
process = cmd.cmdLine != null
? Runtime.getRuntime().exec(cmd.cmdLine, null, workDir)
: Runtime.getRuntime().exec(cmd.cmdParts, null, workDir);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whitespace changes only.

@ialarmedalien ialarmedalien marked this pull request as ready for review June 11, 2020 15:23
Copy link
Member

@MrCreosote MrCreosote left a comment

Choose a reason for hiding this comment

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

This seems mostly innocuous and it's good to have some automated testing even if it doesn't test most of the code base.

That being said, this is critical infrastructure and making changes without having a real test suite running makes me very nervous.

src/java/us/kbase/mobu/ModuleBuilder.java Outdated Show resolved Hide resolved
.github/workflows/kb_sdk-actions.yml Outdated Show resolved Hide resolved
…trieval of information from git.properties file.
…tarting kb-sdk. Add release notes. Fix KBase report class name error in Java version.
@ialarmedalien ialarmedalien force-pushed the java_edits_for_kb_sdk_1.3 branch from a13df0a to 9ac1aba Compare June 16, 2020 16:36
@@ -22,7 +22,7 @@ import assemblyutil.GetAssemblyParams;
import assemblyutil.SaveAssemblyParams;
import kbasereport.CreateParams;
import kbasereport.KBaseReportClient;
import kbasereport.Report;
import kbasereport.SimpleReport;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Java bug fix - incorrect class name.

@ialarmedalien
Copy link
Collaborator Author

@ialarmedalien ialarmedalien requested a review from MrCreosote June 16, 2020 18:42
.github/workflows/kb_sdk-actions.yml Show resolved Hide resolved
return gitCommit;
propertyValue = gitProps.getProperty(propertyToGet);
} catch (Exception e) {
showError("Error while retrieving version information", e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

showError just prints the error, it doesn't exit. I think you'll have to do something else here to stop execution.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it's necessary to stop execution if the git.properties file can't be found or these properties aren't available -- it's basically just adding in some extra "nice to have" information, it isn't mission critical. The properties file is generated during the build process and deleting it afterwards had no effect on the functioning of kb-sdk.

Copy link
Member

Choose a reason for hiding this comment

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

But why not? If it's not there, clearly something went wrong with the build. Reduce runtime variables IMO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My thinking is more along the lines of "I don't want to give kb-sdk a reason to die unexpectedly", plus I couldn't create a situation manually where kb-sdk built successfully but the git.properties file was not present.

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking I don't want unexpected behavior from the SDK when something's broken. I want it to fail fast.

plus I couldn't create a situation manually where kb-sdk built successfully but the git.properties file was not present.

Then failing won't cause any problems in practice unless something is really wrong, so might as well fail.

Copy link
Collaborator Author

@ialarmedalien ialarmedalien Jun 18, 2020

Choose a reason for hiding this comment

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

OK, added a System.exit(1); after emitting the error message.

.github/workflows/kb_sdk-actions.yml Show resolved Hide resolved
.github/workflows/kb_sdk-actions.yml Show resolved Hide resolved
fail-fast: false
matrix:
os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
app: [WsLargeDataIO, KBaseReport]
Copy link
Member

Choose a reason for hiding this comment

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

Hmm... this means if those repos break then kb-sdk test also breaks. I understand why you're doing this but making the sdk build depend on outside repos building and testing correctly seems overly fragile.

Copy link
Member

Choose a reason for hiding this comment

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

Also, neither of these repos test callback server functionality

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What would you suggest here? The tests are kind of moot anyway because the app base images may have a different version of kb-sdk on them, so the build/compile step won't really be testing the revised kb-sdk. There should be something to test that the changes aren't going to break existing repos.

Copy link
Member

Choose a reason for hiding this comment

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

Well personally, I wouldn't test against outside repos and I would depend on a good suite of regression tests and quality PR reviews to ensure that changes don't break repos. So let's just make that happen yeah

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hah! I have some ideas for setting up some better regression tests but I didn't want to put too much into this PR, especially since I am working around the knowledge that kb-sdk v1.1.0 to 1.2.0 introduces breaking changes in the python code which have been masked because the sdkbase repo has not been updated. 🤦

I really wish that the old testing mechanisms had not been disabled!

Copy link
Member

Choose a reason for hiding this comment

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

Were they actually disabled? I just thought that no one could get them to run except me. I'm not even sure if I can get them to run at this point, so I wouldn't be surprised if bitrot had set in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to get them going a while back, but they ran on a VM which has now disappeared, and the config/set up files were removed from the repo.

Copy link
Member

Choose a reason for hiding this comment

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

the config/set up files were removed from the repo

That's just... wow.

.github/workflows/kb_sdk-actions.yml Show resolved Hide resolved
.github/workflows/kb_sdk-actions.yml Show resolved Hide resolved
RELEASE_NOTES.txt Outdated Show resolved Hide resolved
@MrCreosote
Copy link
Member

Java client generated by kb-sdk uses the correct name for KBase report

This still seems off. The Java client doesn't know about the KBase report at all in general. The generated tests for the java module were using an incorrect class name.

@ialarmedalien
Copy link
Collaborator Author

ialarmedalien commented Jun 17, 2020

Java client generated by kb-sdk uses the correct name for KBase report

This still seems off. The Java client doesn't know about the KBase report at all in general. The generated tests for the java module were using an incorrect class name.

"Corrected a class name in the Java client generated by kb-sdk"?

@MrCreosote
Copy link
Member

I would say 'Corrected a class name in the generated tests for the Java SDK module'. It doesn't really have anything to do with the Java client generally.

If you want to be really specific then 'Corrected a class name for the Java KBaseReport client in the generated tests for the Java SDK module'

@ialarmedalien ialarmedalien requested a review from MrCreosote June 18, 2020 20:14
propertyValue = gitProps.getProperty(propertyToGet);
} catch (Exception e) {
showError("Error while retrieving version information from git.properties file: ", e.getMessage());
System.exit(1);
Copy link
Member

Choose a reason for hiding this comment

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

When I was looking at the module builder code earlier, I noticed that most of the methods returned the return code rather than calling exit() themselves. Does that need to happen here? I don't actually understand why they were passing back the return code, but I assume it's for some good reason.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe testability? If you return the code, you can test the method, but not if you call exit().

Copy link
Collaborator Author

@ialarmedalien ialarmedalien Jun 19, 2020

Choose a reason for hiding this comment

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

This happens before any of the module builder methods are called, so you have to just exit. The module builder methods all expect an integer (representing success or otherwise) to be returned:

public static void main(String[] args) throws Exception {
  // code adding the various valid commands and args to JCommander

  // ModuleBuilder line 97: print name and version
  printVersion();

  // parse the arguments and gracefully catch any errors
  try {
    jc.parse(args);
  } catch (RuntimeException e) {
    showError("Command Line Argument Error", e.getMessage());
    System.exit(1);
  }

  // snip some help command stuff

  // if we get here, we have a valid command, so process it and do stuff
  int returnCode = 0;
  if(jc.getParsedCommand().equals(HELP_COMMAND)) {
    showCommandUsage(jc,help,System.out);
  } else if(jc.getParsedCommand().equals(INIT_COMMAND)) {
    returnCode = runInitCommand(initArgs,jc);
  // etc.

Copy link
Member

@MrCreosote MrCreosote left a comment

Choose a reason for hiding this comment

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

Approving with trepidation as the test suite can't be run.

@MrCreosote MrCreosote merged commit ad5e402 into kbase:develop Jun 19, 2020
@ialarmedalien ialarmedalien deleted the java_edits_for_kb_sdk_1.3 branch June 19, 2020 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants