Calling the Model from button


the Button is created based on the callback. now I want to open the model when I click button. the problem is the button is generated by the function which is not part of layout.
Below is the code

def GetStats(hstname):
    es = Elasticsearch(host="", port="19200")
    query = {
        "query": {
	            "bool": {
		            "must": [
			            { "match": { "Hostname": hstname }}
                },"size": 1,
			    "sort": [
				   "@timestamp": {
				   "order": "desc"
    res ="lenel*",  body=query, size=1)
    Services = pd.json_normalize(res['hits']['hits'][0]['_source']['Services'])
    Services.rename(columns={'Name':'Service Name'},inplace=True)
    DownCount = Services['Status'].str.contains('Stopped').sum()
    if DownCount>0:
        clr = "danger"
        clr = "success"
    ServiceTable = dash_table.DataTable(
		columns=[{'id': c, 'name': c} for c in Services.columns],
    card_content = [
    dbc.CardHeader(html.H5(Hostname.upper()), style={'text-align': 'center'}),
            dbc.Row([dbc.Button("Service Status",id="opens" ,color = clr, className="mr-1"),
                             dbc.ModalHeader("Services Status"),
	                         dbc.ModalFooter(dbc.Button("Close", id="closes", className="ml-auto"))
    return (card_content)

app.layout = html.Div(dbc.Col([dbc.Card(id='someid', color="dark", inverse=True)],width=2))

@app.callback(Output('someid', 'children'),
              [Input('interval-component', 'n_intervals')])
def gencard(n):
    A = GetStats("hostnames")
    return A

    Output("modals", "is_open"),
    [Input("opens", "n_clicks"), Input("closes", "n_clicks")],
    [State("modals", "is_open")],
def toggle_modal(n1, n2, is_open):
    if n1 or n2:
        return not is_open
    return is_open

Not Sure what I’m missing here…