Skip to content

[PYTHON] Changes input variable to not conflict with built-in function - #20775

Closed
DylanGuedes wants to merge 3 commits into
apache:masterfrom
DylanGuedes:input_variable
Closed

[PYTHON] Changes input variable to not conflict with built-in function#20775
DylanGuedes wants to merge 3 commits into
apache:masterfrom
DylanGuedes:input_variable

Conversation

@DylanGuedes

Copy link
Copy Markdown
Contributor

Signed-off-by: DylanGuedes djmgguedes@gmail.com

What changes were proposed in this pull request?

Changes variable name conflict: input is a built-in python function.

How was this patch tested?

I runned the example and it works fine.

Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
@HyukjinKwon

Copy link
Copy Markdown
Member

ok to test

"""
An example of how to use DataFrame for ML. Run with::
bin/spark-submit examples/src/main/python/ml/dataframe_example.py <input>
bin/spark-submit examples/src/main/python/ml/dataframe_example.py <dataset>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we change dataset to like .. input_path or path? I think the name dataset is usually used for Dataset instance.

@HyukjinKwon

Copy link
Copy Markdown
Member

I think it's fine. It should better avoid shadowing builtin names but can you check out other examples too while we are here?

@DylanGuedes

Copy link
Copy Markdown
ContributorAuthor

Sure, and thanks for the review! I used the "dataset" name because I checked a few examples that also use it, but I'll rename to path then. I already checked all other examples using grep and this is the only one using "input" name.

@SparkQA

Copy link
Copy Markdown

Test build #88124 has finished for PR 20775 at commit 4685d68.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
@DylanGuedes

Copy link
Copy Markdown
ContributorAuthor

@HyukjinKwon I checked every other built in function and this was the only one being used. What you think?

@SparkQA

Copy link
Copy Markdown

Test build #88125 has finished for PR 20775 at commit 2cb9b57.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwonHyukjinKwon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

# Load input data
print("Loading LIBSVM file with UDT from " + input + ".")
df = spark.read.format("libsvm").load(input).cache()
# Load file from path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's just write it as Load an input file.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
@SparkQA

Copy link
Copy Markdown

Test build #88128 has finished for PR 20775 at commit ae97ceb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@felixcheungfelixcheung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you update the PR title to say [PYTHON] example?

@DylanGuedesDylanGuedes changed the title Changes input variable to not conflict with built-in function[PYTHON] Changes input variable to not conflict with built-in functionMar 10, 2018
@DylanGuedes

Copy link
Copy Markdown
ContributorAuthor

Sure. Done.

@HyukjinKwon

Copy link
Copy Markdown
Member

Merged to master and branch-2.3.

asfgit pushed a commit that referenced this pull request Mar 10, 2018
Signed-off-by: DylanGuedes <djmgguedesgmail.com>
## What changes were proposed in this pull request?
Changes variable name conflict: [input is a built-in python function](https://stackoverflow.com/questions/20670732/is-input-a-keyword-in-python).
## How was this patch tested?
I runned the example and it works fine.
Author: DylanGuedes <djmgguedes@gmail.com>
Closes#20775 from DylanGuedes/input_variable.
(cherry picked from commit b6f837c)
Signed-off-by: hyukjinkwon <gurwls223@gmail.com>
peter-toth pushed a commit to peter-toth/spark that referenced this pull request Oct 6, 2018
Signed-off-by: DylanGuedes <djmgguedesgmail.com>
## What changes were proposed in this pull request?
Changes variable name conflict: [input is a built-in python function](https://stackoverflow.com/questions/20670732/is-input-a-keyword-in-python).
## How was this patch tested?
I runned the example and it works fine.
Author: DylanGuedes <djmgguedes@gmail.com>
Closesapache#20775 from DylanGuedes/input_variable.
(cherry picked from commit b6f837c)
Signed-off-by: hyukjinkwon <gurwls223@gmail.com>
Sign up for freeto 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.

4 participants

@DylanGuedes@HyukjinKwon@SparkQA@felixcheung