title: Dataflow Error: 'Clients have non-trivial state that is local and unpickleable'
body: <p>I have a pipeline that I can execute locally without any errors. I used to get this error in my locally run pipeline </p>
  
  <pre><code>    'Clients have non-trivial state that is local and unpickleable.'
       PicklingError: Pickling client objects is explicitly not supported.
  </code></pre>
  
  <p>I believe I fixed this by downgrading to apache-beam=2.3.0
  Then locally it would run perfectly. </p>
  
  <p>Now I am using <strong>DataflowRunner</strong>  and in the requirements.txt file I have the following dependencies </p>
  
  <pre><code>    apache-beam==2.3.0
      google-cloud-bigquery==1.1.0
      google-cloud-core==0.28.1
      google-cloud-datastore==1.6.0
      google-cloud-storage==1.10.0
      protobuf==3.5.2.post1
      pytz==2013.7
  </code></pre>
  
  <p>but I get this dreaded error again </p>
  
  <pre><code>    'Clients have non-trivial state that is local and unpickleable.'
       PicklingError: Pickling client objects is explicitly not supported.
  </code></pre>
  
  <p>How come it's giving me the error with DataflowRunner but not DirectRunner?  shouldn't they be using the same dependencies/environment? 
  Any help would be appreciated. </p>
  
  <p>I had read that this is the way to solve it but when I try it I still get the same error</p>
  
  <pre><code>    class MyDoFn(beam.DoFn):
  
          def start_bundle(self, process_context):
              self._dsclient = datastore.Client()
  
          def process(self, context, *args, **kwargs):
          # do stuff with self._dsclient
  </code></pre>
  
  <p>from <a href="https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3191" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3191</a></p>
  
  <p>My previous reference post where I fixed this locally:</p>
  
  <p><a href="https://stackoverflow.com/questions/50516665/using-start-bundle-in-apache-beam-job-not-working-unpickleable-storage-client">Using start_bundle() in apache-beam job not working. Unpickleable storage.Client()</a></p>
  
  <p>Thanks in advance! </p>