github.com/apache/beam/sdks/v2@v2.48.2/python/apache_beam/examples/complete/juliaset/juliaset_main.py (about) 1 # 2 # Licensed to the Apache Software Foundation (ASF) under one or more 3 # contributor license agreements. See the NOTICE file distributed with 4 # this work for additional information regarding copyright ownership. 5 # The ASF licenses this file to You under the Apache License, Version 2.0 6 # (the "License"); you may not use this file except in compliance with 7 # the License. You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 """A Julia set computing workflow: https://en.wikipedia.org/wiki/Julia_set. 19 20 This example has in the juliaset/ folder all the code needed to execute the 21 workflow. It is organized in this way so that it can be packaged as a Python 22 package and later installed in the VM workers executing the job. The root 23 directory for the example contains just a "driver" script to launch the job 24 and the setup.py file needed to create a package. 25 26 The advantages for organizing the code is that large projects will naturally 27 evolve beyond just one module and you will have to make sure the additional 28 modules are present in the worker. 29 30 In Python Dataflow, using the --setup_file option when submitting a job, will 31 trigger creating a source distribution (as if running python setup.py sdist) and 32 then staging the resulting tarball in the staging area. The workers, upon 33 startup, will install the tarball. 34 35 Below is a complete command line for running the juliaset workflow remotely as 36 an example: 37 38 python juliaset_main.py \ 39 --job_name juliaset-$USER \ 40 --project YOUR-PROJECT \ 41 --region GCE-REGION \ 42 --runner DataflowRunner \ 43 --setup_file ./setup.py \ 44 --staging_location gs://YOUR-BUCKET/juliaset/staging \ 45 --temp_location gs://YOUR-BUCKET/juliaset/temp \ 46 --coordinate_output gs://YOUR-BUCKET/juliaset/out \ 47 --grid_size 20 48 49 """ 50 51 # pytype: skip-file 52 53 import logging 54 55 from apache_beam.examples.complete.juliaset.juliaset import juliaset 56 57 if __name__ == '__main__': 58 logging.getLogger().setLevel(logging.INFO) 59 juliaset.run()