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

Improve command line handling of the execution app #1083

Merged
merged 4 commits into from
Nov 10, 2014
Merged

Conversation

ianoc
Copy link
Collaborator

@ianoc ianoc commented Oct 19, 2014

The execution app parser wasn't handling non -D hadoop args that the GenericOptionsParser needs correctly. This special cases all the special ones for the GOP


private[this] val hadoopReservedArgs = List("-fs", "-jt", "-files", "-libjars", "-archives")

def extractUserHadoopArgs(args: Array[String]): (Array[String], Array[String]) = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

tests for this function would be great. I think some scalacheck would be nice. Generate random Array[String] args and the non-hadoop args can't be parsable with the GenericOptionsParser.

@johnynek
Copy link
Collaborator

johnynek commented Nov 8, 2014

ping. just wanted a minor refactoring to make the complex fold more readable.

@ianoc
Copy link
Collaborator Author

ianoc commented Nov 10, 2014

Sorry about the delay, been swamped. Should have the changes you requested now + some property based tests


property("Non-hadoop random args will all end up in the right bucket") = forAll { (args: Array[String]) =>
val (hadoopArgs, nonHadoop) = ExecutionApp.extractUserHadoopArgs(args)
val res = hadoopArgs.toArray.isEmpty && nonHadoop.toArray.sameElements(args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

couldn't this fail if we randomly get a string that looks like "-Da=b"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, sort of just relying on that being improbable. I could filter out such
things in here ?

On Monday, November 10, 2014, P. Oscar Boykin notifications@github.com
wrote:

In
scalding-core/src/test/scala/com/twitter/scalding/ExecutionAppProperties.scala:

+import org.scalacheck.Prop.forAll
+import org.scalacheck.Gen.choose
+import org.scalacheck.Prop._
+
+// Be careful here in that Array[String] equality isn't contents based. its java referenced based.
+object ExecutionAppProperties extends Properties("ExecutionApp Properties") {

  • def debugPrint(inputArgs: Array[String], resultingHadoop: HadoopArgs, resultingNonHadoop: NonHadoopArgs): Unit = {
  • val errorMsg = "Input Args: " + inputArgs.map(""" + _ + """).mkString(",") + "\n" +
  •  "Hadoop Args: " + resultingHadoop.toArray.mkString(",") + "\n" +
    
  •  "Non-Hadoop Args: " + resultingNonHadoop.toArray.mkString(",") + "\n"
    
  • sys.error(errorMsg)
  • }
  • property("Non-hadoop random args will all end up in the right bucket") = forAll { (args: Array[String]) =>
  • val (hadoopArgs, nonHadoop) = ExecutionApp.extractUserHadoopArgs(args)
  • val res = hadoopArgs.toArray.isEmpty && nonHadoop.toArray.sameElements(args)

couldn't this fail if we randomly get a string that looks like "-Da=b"


Reply to this email directly or view it on GitHub
https://github.com/twitter/scalding/pull/1083/files#r20097201.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is super improbable, I guess.

johnynek added a commit that referenced this pull request Nov 10, 2014
Improve command line handling of the execution app
@johnynek johnynek merged commit 847d3f1 into develop Nov 10, 2014
@johnynek johnynek deleted the FixExecutionApp branch November 10, 2014 19:00
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.

None yet

2 participants