This repository was archived by the owner on Jul 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 3434from tfrutil import constants
3535
3636
37+ def _get_setup_py_filepath () -> str :
38+ """Returns the file path to the setup.py file.
39+
40+ The location of the setup.py file is needed to run Dataflow jobs.
41+ """
42+
43+ return os .path .join (
44+ os .path .dirname (os .path .abspath (__file__ )), '..' , 'setup.py' )
45+
46+
3747def _get_job_name (job_label : str = None ) -> str :
3848 """Returns Beam runner job name.
3949
@@ -84,7 +94,7 @@ def _get_pipeline_options(
8494 if region :
8595 options_dict ['region' ] = region
8696 if runner == 'DataFlowRunner' :
87- options_dict ['setup_file' ] = os . path . join ( '..' , 'setup.py' )
97+ options_dict ['setup_file' ] = _get_setup_py_filepath ( )
8898 if dataflow_options :
8999 options_dict .update (dataflow_options )
90100
Original file line number Diff line number Diff line change 1616
1717"""Tests for beam_pipeline."""
1818
19+ import os
1920import unittest
2021from unittest import mock
2122
2829# pylint: disable=protected-access
2930
3031class BeamPipelineTests (unittest .TestCase ):
31- """Tests for beam_image .py"""
32+ """Tests for beam_pipeline .py"""
3233
3334 def test_processing_fn_with_int_label (self ):
3435 'Test preprocessing fn with integer label.'
@@ -76,3 +77,9 @@ def test_partition_fn(self):
7677 self .assertEqual (
7778 index , i ,
7879 '{} should be index {} but was index {}' .format (part , i , index ))
80+
81+ def test_get_setup_py_filepath (self ):
82+ """Tests `_get_setup_py_filepath`."""
83+ filepath = beam_pipeline ._get_setup_py_filepath ()
84+ self .assertTrue (os .path .isfile (filepath ))
85+ self .assertTrue (os .path .isabs (filepath ))
You can’t perform that action at this time.
0 commit comments