comparison pyspark/test_timeside_vamp_spark.py @ 0:e34cf1b6fe09 tip

commit
author Daniel Wolff
date Sat, 20 Feb 2016 18:14:24 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e34cf1b6fe09
1 # Part of DML (Digital Music Laboratory)
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 #!/usr/local/spark-1.0.0-bin-hadoop2/bin/spark-submit
18 # -*- coding: utf-8 -*-
19 __author__="wolffd"
20 __date__ ="$11-Jul-2014 15:31:01$"
21
22 from pyspark import SparkConf, SparkContext
23 # @todo: timeside has to be packed for multi-pc usage
24 from timeside_vamp import *
25 from os import walk
26
27 # Running python applications through ./bin/pyspark is deprecated as of Spark 1.0.
28 # Use ./bin/spark-submit <python file>
29
30
31 def main():
32 print "PySpark Telemeta and Vamp Test"
33 conf = (SparkConf()
34 .setMaster("local")
35 .setAppName("My app")
36 .set("spark.executor.memory", "1g"))
37 sc = SparkContext(conf = conf)
38
39 # here come the wav file names
40
41 mypath = '../../TimeSide/tests/samples/'
42 data = []
43 for (dirpath, dirnames, filenames) in walk(mypath):
44 for file in filenames:
45 if file.endswith(".wav"):
46 data.append(os.path.join(dirpath, file))
47
48 # define distributed dataset
49 distData = sc.parallelize(data)
50
51 # define map
52 m1 = distData.map(lambda x: transform(wav_file=x))
53
54 #process 2
55 m1.take(2)
56
57 if __name__ == "__main__":
58 main()
59