Uh oh!
There was an error while loading. Please reload this page.
[SPARK-16992][PYSPARK][DOCS] import sort and autopep8 on Pyspark examples - #14830
[SPARK-16992][PYSPARK][DOCS] import sort and autopep8 on Pyspark examples#14830gsemet wants to merge 5 commits into
Conversation
7848c92 to
493ae5cCompare54c5fdf to
2e28dd6CompareSparkQA
commented
Aug 26, 2016
Test build #64473 has finished for PR 14830 at commit
|
SparkQA
commented
Aug 26, 2016
Test build #64471 has finished for PR 14830 at commit
|
srowen
commented
Aug 26, 2016
There was a problem hiding this comment.
So we might want to move the
There was a problem hiding this comment.
ok. what does this tag do ?
There was a problem hiding this comment.
Some of the examples files are used in generating the website documentation, and the "example on" and "example off" tags are used to determine which parts get pulled in to the website (in this case this is done since we don't want to have the same boiler plate imports for each example - rather showing the ones specific to that). You can take a look at ./docs/ml-features.md which includes this file to see how its used in markdown and the generated website documentation at http://spark.apache.org/docs/latest/ml-features.html#binarizer .
The instructions for building the docs locally are located at ./docs/README.md - let me know if you need any help with that - the documentation build is sometimes a bit overlooked since many of the developers don't build it manually often.
There was a problem hiding this comment.
yes I see, makes perfectly sense !
There was a problem hiding this comment.
So we probably want to fix that here and in other places.
holdenk
commented
Aug 27, 2016
Thank for taking the time to do this @stibbons I think its great progress. Doing a quick skim it seems like there are a number of places where the import reordering may have inadvertanly changed what the users will see in the examples we have in the documentation - which is probably not what was intended. I've left line comments in some of the places where I noticed them but there are probably quite a few others since it was just a quick first skim. I'd suggest doing a quick audit yourself and then consider building the documentation to verify that it hasn't changed in any unintended ways by your change. Once again thanks for taking on this task! :) |
gsemet
commented
Aug 27, 2016
yes, i will try to understand how it works and make it beautiful. The goal is to move toward an automation of such code housework, but it may take some time. I'll continue to submit part of this code style work next week, so we can see "small" changes like this. I really like "yapf", a formatting tool from google that almost do the job, better that autopep8. it works a bit aggressively, that why I do not recommend to enforce using it, but it helps identifying and rework most pep8 errors in Python. |
There was a problem hiding this comment.
I actually prefer this line be in the doc
There was a problem hiding this comment.
In that case, move the # $example on$ comment up above the from pyspark.ml.linalg import Vectors
50fc56e to
2635dcbComparegsemet
commented
Aug 29, 2016
Here is a new proposal. I've taken into account your remark, hope all $on/$off things are ok, and added some minor rework with the multiline syntax (I find using \ weird and inelegant, using parenthesis "()" make is more readable, TMHO). Tell me what you think about this |
holdenk
commented
Aug 29, 2016
For what its worth pep8 says:
So this sounds like keeping in line with the general more pep8ification of the code - but I am a little concerned about just how many files this touches now that it isn't just an autogenerated change*, but I'll try and set aside some time this week to review it (I'm currently ~13 hours off my regular timezone so my review times may be a little erratic). |
gsemet
commented
Aug 29, 2016
Cool I wasn't sure of it. No pbl, I can even split it into several PR |
There was a problem hiding this comment.
I have not changed all this initilization lines, since they do not appear most of the time in the documentation
ff6aabf to
78b66d8CompareSparkQA
commented
Jan 9, 2017
Test build #71079 has finished for PR 14830 at commit
|
holdenk
left a comment
There was a problem hiding this comment.
It seems I let this slip my radar (sorry). Some minor comments, but if you're ok with updating this to master I can now merge Python PRs and it would be nice to have our examples cleaned up in this way. Sorry @stibbons for the delay.
There was a problem hiding this comment.
Why did you remove the double newlines after the end of the imports?
gsemet
left a comment
There was a problem hiding this comment.
Fixed your remarks. The extra line has been emptied (no need for the '#'). It is the pep8 recomendation to have 2 empty lines after imports.
I have fixed the other remark as well
thanks
SparkQA
commented
Feb 14, 2017
Test build #72861 has finished for PR 14830 at commit
|
SparkQA
commented
Feb 14, 2017
Test build #72862 has finished for PR 14830 at commit
|
holdenk
commented
Feb 14, 2017
Great, thanks for updating this :) Would be good to see if @HyukjinKwon has anything to say otherwise I'll do another pass through this tomorrow and hopefully its really close :) |
HyukjinKwon
commented
Feb 14, 2017
Thank you for cc'ing me @holdenk. Let me try to take a look within tomorrow too at my best. |
There was a problem hiding this comment.
I left several comments. In general, I think we should minimise the changes as possible as we can. Could we check if they really are recommended changes all (at least the ones I commented)?
I know it sounds a bit demanding but I a bit suspect some changes are not really explicitly required/recommended and some removed lines are not explicitly discouraged. I worry if it is worth sweeping all.
There was a problem hiding this comment.
It'd great if we have some references or quotes.
| [ | ||
| (0, "a b c".split(" ")), | ||
| (1, "a b b c a".split(" ")) | ||
| ], |
There was a problem hiding this comment.
Could you double check if it really does not follow pep8? I have seen the removed syntax more often (e.g., numpy).
There was a problem hiding this comment.
Indeed, this is a recommendation not an obligation. I see it to be more looking like Scala multi-line code, and I prefer it. It is a personal opinion, and I don't think there is a pylint/pep8 check to prevent using .
| # Select (prediction, true label) and compute test error | ||
| evaluator = MulticlassClassificationEvaluator( | ||
| labelCol="indexedLabel", predictionCol="prediction", metricName="accuracy") |
There was a problem hiding this comment.
Hm.. dose pep8 has a different argument location rule for class and function? It seems this one is already fine and seems inconsistent with https://github.com/apache/spark/pull/14830/files#diff-82fe155d22aaaf433e949193d262c736R43
There was a problem hiding this comment.
pep8 tool does this automatically if line is > 100 char. There is indeed no preference between this format and:
evaluator = MulticlassClassificationEvaluator(labelCol="indexedLabel",
predictionCol="prediction",
metricName="accuracy")
I would say both are equivalent. I tend to prefere this one (the latter)
| .transform(lambda rdd: rdd.sortByKey(False)) | ||
| happiest_words = (word_counts | ||
| .map(lambda word_tuples: (word_tuples[0], | ||
| float(word_tuples[1][0]) * word_tuples[1][1])) |
There was a problem hiding this comment.
(Personally, I think it is not more readable..)
There was a problem hiding this comment.
I agree, if you prefer I can change all at once. But like I said, I don't know any autoformat that does it automatically
| from pyspark.mllib.regression import LabeledPoint | ||
| from pyspark.mllib.regression import StreamingLinearRegressionWithSGD | ||
| from pyspark.mllib.regression import (LabeledPoint, | ||
| StreamingLinearRegressionWithSGD) |
There was a problem hiding this comment.
This does not exceed 100 line length? Up to my knowledge Spark limits it 100 (not default 80).
There was a problem hiding this comment.
I actually prefer having a single import per line (this simplifies a lot file management, multi branch merges,...). I can revert this change
| from pyspark.mllib.classification import NaiveBayes, NaiveBayesModel | ||
| from pyspark.mllib.util import MLUtils | ||
There was a problem hiding this comment.
Could I ask to check if the example rendered in doc still complies pep8?
There was a problem hiding this comment.
If you happen to be not able to build the python doc, I will check tomorrow to help.
There was a problem hiding this comment.
yes, because the 2 empty lines are after
# $example off$
HyukjinKwon
commented
Feb 15, 2017
@stibbons are there maybe some options in autopep8 to minimise the changes? (just in case I believe we ignore some rules such as E402,E731,E241,W503 and E226 in Spark). |
gsemet
commented
Feb 15, 2017
Hello. This is actually the execution of the pylint/autopep8 config proposed in #14963. I can minimize a little bit more this PR by ignoring indeed more rules. |
HyukjinKwon
commented
Feb 15, 2017
holdenk
commented
Feb 24, 2017
lets do a jenkins re-run just to make sure everything is up to date and I'll try and get a final pass done soon. I think it would be good to improve our examples to be closer to pep8 style for the sake of readability for people coming from different Python code bases trying to learn PySpark. |
holdenk
commented
Feb 24, 2017
Jenkins retest this please. |
SparkQA
commented
Feb 24, 2017
Test build #73445 has finished for PR 14830 at commit
|
holdenk
commented
Apr 9, 2017
Jenkins retest this please. |
SparkQA
commented
Apr 9, 2017
Test build #75632 has finished for PR 14830 at commit
|
gsemet
commented
Apr 9, 2017
I guess a rebased will be welcomed, I can do it by tomorow if you want |
holdenk
commented
Apr 11, 2017
Sure, if you have a chance to rebase & check if any other changes are needed that would be useful. |
ueshin
commented
Jun 26, 2017
Hi, are you still working on this? |
holdenk
commented
Jul 2, 2017
Gentle follow up ping. I've got some bandwith next week. |
gsemet
commented
Jul 2, 2017
Hello. Sadly I cannot work on this we are in a middle of a big restructuration at work. |
## What changes were proposed in this pull request? This PR proposes to close stale PRs, mostly the same instances with apache#18017Closesapache#14085 - [SPARK-16408][SQL] SparkSQL Added file get Exception: is a directory … Closesapache#14239 - [SPARK-16593] [CORE] [WIP] Provide a pre-fetch mechanism to accelerate shuffle stage. Closesapache#14567 - [SPARK-16992][PYSPARK] Python Pep8 formatting and import reorganisation Closesapache#14579 - [SPARK-16921][PYSPARK] RDD/DataFrame persist()/cache() should return Python context managers Closesapache#14601 - [SPARK-13979][Core] Killed executor is re spawned without AWS key… Closesapache#14830 - [SPARK-16992][PYSPARK][DOCS] import sort and autopep8 on Pyspark examples Closesapache#14963 - [SPARK-16992][PYSPARK] Virtualenv for Pylint and pep8 in lint-python Closesapache#15227 - [SPARK-17655][SQL]Remove unused variables declarations and definations in a WholeStageCodeGened stage Closesapache#15240 - [SPARK-17556] [CORE] [SQL] Executor side broadcast for broadcast joins Closesapache#15405 - [SPARK-15917][CORE] Added support for number of executors in Standalone [WIP] Closesapache#16099 - [SPARK-18665][SQL] set statement state to "ERROR" after user cancel job Closesapache#16445 - [SPARK-19043][SQL]Make SparkSQLSessionManager more configurable Closesapache#16618 - [SPARK-14409][ML][WIP] Add RankingEvaluator Closesapache#16766 - [SPARK-19426][SQL] Custom coalesce for Dataset Closesapache#16832 - [SPARK-19490][SQL] ignore case sensitivity when filtering hive partition columns Closesapache#17052 - [SPARK-19690][SS] Join a streaming DataFrame with a batch DataFrame which has an aggregation may not work Closesapache#17267 - [SPARK-19926][PYSPARK] Make pyspark exception more user-friendly Closesapache#17371 - [SPARK-19903][PYSPARK][SS] window operator miss the `watermark` metadata of time column Closesapache#17401 - [SPARK-18364][YARN] Expose metrics for YarnShuffleService Closesapache#17519 - [SPARK-15352][Doc] follow-up: add configuration docs for topology-aware block replication Closesapache#17530 - [SPARK-5158] Access kerberized HDFS from Spark standalone Closesapache#17854 - [SPARK-20564][Deploy] Reduce massive executor failures when executor count is large (>2000) Closesapache#17979 - [SPARK-19320][MESOS][WIP]allow specifying a hard limit on number of gpus required in each spark executor when running on mesos Closesapache#18127 - [SPARK-6628][SQL][Branch-2.1] Fix ClassCastException when executing sql statement 'insert into' on hbase table Closesapache#18236 - [SPARK-21015] Check field name is not null and empty in GenericRowWit… Closesapache#18269 - [SPARK-21056][SQL] Use at most one spark job to list files in InMemoryFileIndex Closesapache#18328 - [SPARK-21121][SQL] Support changing storage level via the spark.sql.inMemoryColumnarStorage.level variable Closesapache#18354 - [SPARK-18016][SQL][CATALYST][BRANCH-2.1] Code Generation: Constant Pool Limit - Class Splitting Closesapache#18383 - [SPARK-21167][SS] Set kafka clientId while fetch messages Closesapache#18414 - [SPARK-21169] [core] Make sure to update application status to RUNNING if executors are accepted and RUNNING after recovery Closesapache#18432 - resolve com.esotericsoftware.kryo.KryoException Closesapache#18490 - [SPARK-21269][Core][WIP] Fix FetchFailedException when enable maxReqSizeShuffleToMem and KryoSerializer Closesapache#18585 - SPARK-21359 Closesapache#18609 - Spark SQL merge small files to big files Update InsertIntoHiveTable.scala Added: Closesapache#18308 - [SPARK-21099][Spark Core] INFO Log Message Using Incorrect Executor I… Closesapache#18599 - [SPARK-21372] spark writes one log file even I set the number of spark_rotate_log to 0 Closesapache#18619 - [SPARK-21397][BUILD]Maven shade plugin adding dependency-reduced-pom.xml to … Closesapache#18667 - Fix the simpleString used in error messages Closesapache#18782 - Branch 2.1 Added: Closesapache#17694 - [SPARK-12717][PYSPARK] Resolving race condition with pyspark broadcasts when using multiple threads Added: Closesapache#16456 - [SPARK-18994] clean up the local directories for application in future by annother thread Closesapache#18683 - [SPARK-21474][CORE] Make number of parallel fetches from a reducer configurable Closesapache#18690 - [SPARK-21334][CORE] Add metrics reporting service to External Shuffle Server Added: Closesapache#18827 - Merge pull request 1 from apache/master ## How was this patch tested? N/A Author: hyukjinkwon <gurwls223@gmail.com> Closesapache#18780 from HyukjinKwon/close-prs.
This is a set of files that has been formatted by the script defined in #14567.
Not all files are formatted, only the documentation examples, for information sake.
This Pull Request can be merged alone, but it makes more sens to merge it once #14567 is accepted and merged (comes on top of it)