Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates the test suite to use the transform service #30605

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add content here and check it in like 97f8dae for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Empty file.
16 changes: 14 additions & 2 deletions sdks/python/apache_beam/io/gcp/bigtableio_it_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def setUp(self):
self.table = self.instance.table(self.TABLE_ID)
self.table.create()
_LOGGER.info("Created table [%s]", self.table.table_id)
if (os.environ.get('TRANSFORM_SERVICE_PORT')):
self._transform_service_address = (
'localhost:' + os.environ.get('TRANSFORM_SERVICE_PORT'))
else:
self._transform_service_address = None

def tearDown(self):
try:
Expand Down Expand Up @@ -142,7 +147,8 @@ def test_read_xlang(self):
| bigtableio.ReadFromBigtable(
project_id=self.project,
instance_id=self.instance.instance_id,
table_id=self.table.table_id)
table_id=self.table.table_id,
expansion_service=self._transform_service_address)
| "Extract cells" >> beam.Map(lambda row: row._cells))

assert_that(cells, equal_to(expected_cells))
Expand Down Expand Up @@ -190,6 +196,11 @@ def setUp(self):
(self.TABLE_ID, str(int(time.time())), secrets.token_hex(3)))
self.table.create()
_LOGGER.info("Created table [%s]", self.table.table_id)
if (os.environ.get('TRANSFORM_SERVICE_PORT')):
self._transform_service_address = (
'localhost:' + os.environ.get('TRANSFORM_SERVICE_PORT'))
else:
self._transform_service_address = None

def tearDown(self):
try:
Expand All @@ -216,7 +227,8 @@ def run_pipeline(self, rows):
project_id=self.project,
instance_id=self.instance.instance_id,
table_id=self.table.table_id,
use_cross_language=True))
use_cross_language=True,
expansion_service=self._transform_service_address))

def test_set_mutation(self):
row1: DirectRow = DirectRow('key-1')
Expand Down
24 changes: 19 additions & 5 deletions sdks/python/expansion-service-container/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func installExtraPackages(requirementsFile string) error {
return nil
}

func getUpdatedRequirementsFile(oldRequirementsFileName string, dependenciesDir string) (string, error) {
oldExtraPackages, err := getLines(filepath.Join(dependenciesDir, oldRequirementsFileName))
func getUpdatedRequirementsFile(oldDependenciesRequirementsFile string, dependenciesDir string) (string, error) {
oldExtraPackages, err := getLines(oldDependenciesRequirementsFile)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -145,9 +145,20 @@ func launchExpansionServiceProcess() error {

args := []string{"-m", expansionServiceEntrypoint, "-p", strconv.Itoa(*port), "--fully_qualified_name_glob", "*"}

if *requirements_file != "" {
log.Printf("Received the requirements file %v", *requirements_file)
updatedRequirementsFileName, err := getUpdatedRequirementsFile(*requirements_file, *dependencies_dir)
// Requirements file with dependencies to install.
// Note that we have to look for the requirements file in the dependencies
// volume here not the requirements file at the top level. Latter provides
// Beam dependencies.
dependencies_requirements_file := filepath.Join(*dependencies_dir, *requirements_file)
dependencies_requirements_file_exists := false
if _, err := os.Stat(dependencies_requirements_file); err == nil {
dependencies_requirements_file_exists = true
}

// We only try to install dependencies, if the requirements file exists.
if dependencies_requirements_file_exists {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here seems off, this should be in line with the comment, right?

Non-blocking for this PR, but seems like we should catch this with a go fmt check. It would be good to bring all the boot.go files under

run: cd sdks/go/pkg/beam && go fmt ./...; git diff-index --quiet HEAD || (echo "Run go fmt before checking in changes" && exit 1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this pr, could you run go fmt boot.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

log.Printf("Received the requirements file %s with extra packages.", dependencies_requirements_file)
updatedRequirementsFileName, err := getUpdatedRequirementsFile(dependencies_requirements_file, *dependencies_dir)
if err != nil {
return err
}
Expand All @@ -161,7 +172,10 @@ func launchExpansionServiceProcess() error {
if err != nil {
return err
}
} else {
log.Printf("Requirements file %s was provided but not available.", dependencies_requirements_file)
}

if err := execx.Execute(pythonVersion, args...); err != nil {
return fmt.Errorf("could not start the expansion service: %s", err)
}
Expand Down
Loading