beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Work logged] (BEAM-3883) Python SDK stages artifacts when talking to job server
Date Tue, 22 May 2018 17:22:00 GMT


ASF GitHub Bot logged work on BEAM-3883:

                Author: ASF GitHub Bot
            Created on: 22/May/18 17:21
            Start Date: 22/May/18 17:21
    Worklog Time Spent: 10m 
      Work Description: tvalentyn commented on a change in pull request #5273: [BEAM-3883]
Adding Client to push artifacts to artifact staging service

 File path: sdks/python/apache_beam/runners/portability/
 @@ -0,0 +1,148 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Test cases for :module:`artifact_service_client`."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+import filecmp
+import logging
+import os
+import random
+import shutil
+import string
+import tempfile
+import unittest
+from concurrent import futures
+import grpc
+from apache_beam.portability.api import beam_artifact_api_pb2
+from apache_beam.portability.api import beam_artifact_api_pb2_grpc
+from apache_beam.runners.portability import portable_stager
+class PortableStagerTest(unittest.TestCase):
+  def setUp(self):
+    self._temp_dir = tempfile.mkdtemp()
+    self._remote_dir = tempfile.mkdtemp()
+  def tearDown(self):
+    if self._temp_dir:
+      shutil.rmtree(self._temp_dir)
+    if self._remote_dir:
+      shutil.rmtree(self._remote_dir)
+  def stage_files(self, files):
+    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+    beam_artifact_api_pb2_grpc.add_ArtifactStagingServiceServicer_to_server(
+        TestLocalFileSystemArtifactStagingServiceServicer(self._remote_dir),
+        server)
+    test_port = server.add_insecure_port('[::]:0')
+    server.start()
+    stager = portable_stager.PortableStager(
+        grpc.insecure_channel('localhost:%s' % test_port))
+    for from_file, to_file in files:
+      stager.stage_artifact(
+          local_path_to_artifact=os.path.join(self._temp_dir, from_file),
+          artifact_name=to_file)
+    return stager._artifacts
+  def test_stage_single_file(self):
+    from_file = 'test_local.txt'
+    to_file = 'test_remote.txt'
+    with open(os.path.join(self._temp_dir, from_file), 'wb') as f:
+      f.write(b'abc')
+    copied_files = self.stage_files([('test_local.txt', 'test_remote.txt')])
+    self.assertTrue(
+        filecmp.cmp(
+            os.path.join(self._temp_dir, from_file),
+            os.path.join(self._remote_dir, to_file)))
+    self.assertEqual([to_file], [ for manifest in copied_files])
 Review comment:
   Manifest is a **list** of staged files, so it's not the best name for the loop variable
here. If we want to check that manifest is created and staged, I would actually exercise commit_manifest

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

Issue Time Tracking

    Worklog Id:     (was: 104702)
    Time Spent: 17h  (was: 16h 50m)

> Python SDK stages artifacts when talking to job server
> ------------------------------------------------------
>                 Key: BEAM-3883
>                 URL:
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: Ben Sidhom
>            Assignee: Ankur Goenka
>            Priority: Major
>          Time Spent: 17h
>  Remaining Estimate: 0h
> The Python SDK does not currently stage its user-defined functions or dependencies when
talking to the job API. Artifacts that need to be staged include the user code itself, any
SDK components not included in the container image, and the list of Python packages that must
be installed at runtime.
> Artifacts that are currently expected can be found in the harness boot code: []

This message was sent by Atlassian JIRA

View raw message