-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the 2nd set of functionality and many more widgets
- Loading branch information
Showing
29 changed files
with
445 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,6 @@ | ||
# Category metadata. | ||
|
||
# Category icon show in the menu | ||
ICON = "icons/category.ico" | ||
|
||
# Background color for category background in menu | ||
# and widget icon background in workflow. | ||
#BACKGROUND = "light-orange" | ||
BACKGROUND = "white" | ||
|
||
# Location of widget help files. | ||
WIDGET_HELP_PATH = ( | ||
# Used for development. | ||
# You still need to build help pages using | ||
# make htmlhelp | ||
# inside doc folder | ||
("{DEVELOP_ROOT}/doc/build/htmlhelp/index.html", None), | ||
|
||
("http://spark.com/my-widget/docs/", "") | ||
) | ||
__author__ = "Jose Antonio Martin H." | ||
__copyright__ = "Copyright 2015, Jose Antonio Martin H." | ||
__credits__ = ["The Orange Machine Learning Project, Jose Antonio Martin H. "] | ||
__license__ = "Apache License 2.0" | ||
__maintainer__ = "JOse Antonio Martin H." | ||
__email__ = "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
__author__ = "Jose Antonio Martin H." | ||
__copyright__ = "Copyright 2015, Jose Antonio Martin H." | ||
__credits__ = ["The Orange Machine Learning Project, Jose Antonio Martin H. "] | ||
__license__ = "Apache License 2.0" | ||
__maintainer__ = "JOse Antonio Martin H." | ||
__email__ = "[email protected]" | ||
|
||
|
||
# Category metadata. | ||
|
||
# Category icon show in the menu | ||
ICON = "../icons/category.ico" | ||
|
||
# Background color for category background in menu | ||
# and widget icon background in workflow. | ||
#BACKGROUND = "light-orange" | ||
BACKGROUND = "white" | ||
|
||
# Location of widget help files. | ||
WIDGET_HELP_PATH = ( | ||
# Used for development. | ||
# You still need to build help pages using | ||
# make htmlhelp | ||
# inside doc folder | ||
("{DEVELOP_ROOT}/doc/build/htmlhelp/index.html", None), | ||
|
||
("http://spark.com/my-widget/docs/", "") | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
__author__ = 'jamh' | ||
|
||
import pandas | ||
from Orange.data import Table | ||
from Orange.widgets import widget, gui, settings | ||
|
||
from orangecontrib.spark.utils.bdutils import orange_to_pandas | ||
|
||
|
||
class OWOrangeToPandas(widget.OWWidget): | ||
name = "to Pandas" | ||
description = "Convert Orange Table to Pandas DataFrame" | ||
icon = "../icons/orange.ico" | ||
|
||
inputs = [("Table", Table, "get_input", widget.Default)] | ||
outputs = [("Pandas", pandas.DataFrame, widget.Dynamic)] | ||
settingsHandler = settings.DomainContextHandler() | ||
|
||
def __init__(self): | ||
super().__init__() | ||
gui.label(self.controlArea, self, "to pandas:") | ||
|
||
def get_input(self, obj): | ||
self.send("Pandas", orange_to_pandas(obj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
__author__ = 'jamh' | ||
|
||
import pyspark | ||
from Orange.data import Table | ||
from Orange.widgets import widget, gui, settings | ||
|
||
from orangecontrib.spark.base.shared_spark_context import SharedSparkContext | ||
from orangecontrib.spark.utils.bdutils import orange_to_pandas | ||
|
||
|
||
class OWSparkFromOrange(SharedSparkContext, widget.OWWidget): | ||
name = "from Orange" | ||
description = "Convert Orange Table to Spark DataFrame" | ||
icon = "../icons/spark.ico" | ||
|
||
inputs = [("Table", Table, "get_input", widget.Default)] | ||
outputs = [("DataFrame", pyspark.sql.DataFrame, widget.Dynamic)] | ||
settingsHandler = settings.DomainContextHandler() | ||
|
||
auto_commit = settings.Setting(True) | ||
|
||
def __init__(self): | ||
super().__init__() | ||
gui.label(self.controlArea, self, "From Oranges:") | ||
|
||
def get_input(self, obj): | ||
self.send("DataFrame", self.hc.createDataFrame(orange_to_pandas(obj))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
__author__ = 'jamh' | ||
|
||
import pandas | ||
import pyspark | ||
from Orange.widgets import widget, gui, settings | ||
from PyQt4.QtGui import QSizePolicy | ||
|
||
from orangecontrib.spark.base.shared_spark_context import SharedSparkContext | ||
|
||
|
||
class OWSparkToPandas(SharedSparkContext, widget.OWWidget): | ||
name = "from Pandas" | ||
description = "Convert Pandas dataframe to Spark DataFrame." | ||
icon = "../icons/spark.ico" | ||
|
||
inputs = [("DataFrame", pandas.DataFrame, "get_input", widget.Default)] | ||
outputs = [("DataFrame", pyspark.sql.DataFrame, widget.Dynamic)] | ||
settingsHandler = settings.DomainContextHandler() | ||
|
||
def __init__(self): | ||
super().__init__() | ||
gui.label(self.controlArea, self, "Pandas->Spark:") | ||
self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) | ||
|
||
def get_input(self, obj): | ||
self.send("DataFrame", self.hc.createDataFrame(obj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 6 additions & 14 deletions
20
...econtrib/spark/widgets/spark_to_pandas.py → ...rib/spark/widgets/data/spark_to_pandas.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
__author__ = 'jamh' | ||
|
||
from Orange.data import Table | ||
from PyQt4.QtGui import QSizePolicy | ||
from Orange.widgets import widget, gui | ||
from orangecontrib.spark.utils.bdutils import pandas_to_orange | ||
import pandas | ||
from Orange.widgets import widget, gui, settings | ||
from pyspark import SparkConf, SparkContext | ||
import pyspark | ||
from Orange.widgets import widget, gui, settings | ||
from PyQt4.QtGui import QSizePolicy | ||
|
||
|
||
class OWSparkToPandas(widget.OWWidget): | ||
name = "to pandas" | ||
name = "to Pandas" | ||
description = "Convert Spark dataframe to Pandas" | ||
icon = "icons/spark.ico" | ||
icon = "../icons/spark.ico" | ||
|
||
inputs = [("Sparkdf", pyspark.sql.DataFrame, "get_input", widget.Default)] | ||
inputs = [("DataFrame", pyspark.sql.DataFrame, "get_input", widget.Default)] | ||
outputs = [("Dataframe", pandas.DataFrame, widget.Dynamic)] | ||
settingsHandler = settings.DomainContextHandler() | ||
|
||
NOTHING = "Nothing on input" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.obj_type = self.NOTHING | ||
gui.label(self.controlArea, self, "Spark->Pandas:") | ||
self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) | ||
|
||
def get_input(self, obj): | ||
self.obj_type = self.NOTHING if obj is None else type(obj).__name__ | ||
|
||
self.send("Table", obj.toPandas()) | ||
self.send("Dataframe", obj.toPandas()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.