title: Plotly Dash: Chained callbacks are working fine, but always throw ValueError. How to fix or silence?
body: <p>I have a dataset that lists different jobs and what tools are need by date and location. Here is a tiny example of my df:</p>
  <pre><code>State,County,Job,Tool,Start,End
  LA,Acadia,A,Hammer,2020-10-19,2020-11-02
  LA,Acadia,A,Drill,2020-11-02,2020-12-02
  LA,Acadia,B,Hammer,2020-11-28,2020-12-30
  LA,Orleans,A,Hammer,2020-10-03,2020-11-02
  LA,Orleans,A,Drill,2020-11-05,2020-12-02
  LA,Orleans,B,Hammer,2020-12-03,2020-12-30
  TX,Travis,A,Hammer,2020-10-19,2020-11-02
  TX,Travis,A,Drill,2020-11-02,2020-12-02
  TX,Travis,B,Hammer,2020-11-28,2020-12-30
  TX,Brazoria,A,Hammer,2020-10-03,2020-11-02
  TX,Brazoria,A,Drill,2020-11-05,2020-12-02
  TX,Brazoria,B,Hammer,2020-12-03,2020-12-30
  </code></pre>
  <p>My dcc.Dropdowns and dcc.RadioItems are as follows:</p>
  <pre><code>        html.Div([
              html.Label(&quot;State:&quot;, style={'fontSize': 30, 'textAlign': 'center'}),
              dcc.Dropdown(
                  id='state-dpdn',
                  options=[{'label': s, 'value': s} for s in sorted(df.State.unique())],
                  value='LA',
                  clearable=False,
              )],
          html.Div([
              html.Label(&quot;County:&quot;, style={'fontSize': 30, 'textAlign': 'center'}),
              dcc.Dropdown(
                  id='county-dpdn',
                  options=[],
                  value=[],
                  clearable=False
              )],
          html.Div([
              html.Label(&quot;Job:&quot;, style={'fontSize': 30, 'textAlign': 'center'}),
              dcc.RadioItems(
                  id='radio-buttons',
                  options=[],
              ),
  </code></pre>
  <p>And here are my callbacks:</p>
  <pre><code>    @app.callback(
          Output('county-dpdn', 'options'),
          Output('county-dpdn', 'value'),
          Input('state-dpdn', 'value'),
      )
      def set_county_options(chosen_state):
          dff = df[df.State == chosen_state]
          counties_of_state = [{'label': c, 'value': c} for c in sorted(dff.County.unique())]
          values_selected = [x['value'] for x in counties_of_state]
          return counties_of_state, values_selected
  
      @app.callback(
          Output('radio-buttons', 'options'),
          Output('radio-buttons', 'value'),
          Input('county-dpdn', 'value'),
      )
      def set_job_options(chosen_county):
          dff = df[df.County == chosen_county] ###THIS IS LINE 255 W/ ERROR###
          job_of_county = [{'label': c, 'value': c} for c in dff.Job.unique()]
          values_selected = job_of_county[0]['value']
          return job_of_county, values_selected
  
      @app.callback(
          Output('graph1', 'children'),
          Input('radio-buttons', 'value'),
          Input('county-dpdn', 'value'),
          Input('state-dpdn', 'value')
      )
      def build_graph(job_selected, location_selected, state_selected):
          if isinstance(state_selected, str):
              df['State'].eq(state_selected)
  
          if isinstance(location_selected, str):
              df['County'].eq(location_selected)
  
          if isinstance(job_selected, str):
              df['Job'].eq(job_selected)
  
          dffgraph = df[df['State'].eq(state_selected) &amp; df['County'].eq(location_selected) &amp; df['Job'].eq(job_selected)]
  
          ###dffgraph manipulation and figure creation down here###
  
  </code></pre>
  <p>All of this works, loads the data as intended, and my graphs are great. My problem comes when trying to get this out to users without throwing errors. Errors were helpful in constructing everything but when it came time to tweak the presentation of my graphs, I silenced the errors to come back to them later using dev_tools:</p>
  <pre><code>if __name__ == '__main__':
      app.run_server(debug=False, port=5000, dev_tools_ui=False, dev_tools_props_check=False)
  </code></pre>
  <p>I am creating a multipage dash app which works great, but when I put this code into my main multipage app or if I remove the dev tools from the local 'app.run_server' shown above I get the following error:</p>
  <pre><code>File &quot;/Users/Documents/pythonProject/app.py&quot;, line 255, in set_job_options
  dff = df[df.County == chosen_county]
  File &quot;/Users/venv/lib/python3.7/site-packages/pandas/core/ops/common.py&quot;, line 65, in new_method
  return method(self, other)
  File &quot;/Users/venv/lib/python3.7/site-packages/pandas/core/ops/__init__.py&quot;, line 370, in wrapper
  res_values = comparison_op(lvalues, rvalues, op)
  File &quot;/Users/venv/lib/python3.7/site-packages/pandas/core/ops/array_ops.py&quot;, line 225, in comparison_op
  &quot;Lengths must match to compare&quot;, lvalues.shape, rvalues.shape
  ValueError: ('Lengths must match to compare', (4781,), (64,))
  </code></pre>
  <p>The csv file used for creating my df is 4781 lines long, and 64 is the number of parishes in Louisiana, so the number make sense.</p>
  <p>While ignoring this error has worked thus far, after weeks of trying to occasionally figure this out I would love some help with this error. Thank you!</p>
  <p><em><strong>Edit 1</strong></em></p>
  <p>For help with simply silencing the errors, it is best to show how my app is setup. I have a multipage Flask app, with my Dash app being called when the user is directed to it.</p>
  <p>My dashboard.py file looks like:</p>
  <pre><code>def init_dashboard(server):
      &quot;&quot;&quot;Create a Plotly Dash dashboard.&quot;&quot;&quot;
      dash_app = dash.Dash(
          server=server,
          routes_pathname_prefix='/dashapp/',
          external_stylesheets=[dbc.themes.FLATLY]
      )
  
      # Load DataFrame
      df = create_dataframe()
  
      and so on....
  
      return dash_app.server
  </code></pre>
  <p>The <strong>init</strong>.py file in my flask app that calls my dashboard.py:</p>
  <pre><code>def create_app(config_class=Config):
      app = Flask(__name__)
      app.config.from_object(config_class)
  
      .... all the normal init stuff ....
  
      from .plotlydash.dashboard import init_dashboard
      app = init_dashboard(app)
  
      return app
  </code></pre>
  <p>Prior to deployment while testing my dash app as a single entity, debug=False, dev_tools_ui=False, dev_tools_props_check=False all work well to silence the dash errors. When I put my working dash app into my flask app as shown above it still works just fine, but it throws errors which are logged and sent to my email like crazy. I've tried a few different approaches to silencing only the errors from my dash app but haven't found a solution yet.</p>