Giter VIP home page Giter VIP logo

Comments (3)

addypy avatar addypy commented on June 15, 2024 1

@hearsid
I was able to reproduce this error. When you initializate the DataGovIndia class with your API_KEY, it downloads the latest meta-data (list of APIs, titles, description etc.) and stores it in memory. Since these are python objects, it is possible that the streamlit cache isn't able to store them.

However, I looked at their documentation, and I was able to make it work by adding an additional kwarg (allow_output_mutation=True) in the @st.cache decorator.

This is what I used -

import os
from datagovindia import DataGovIndia
import streamlit as st
API_KEY = os.environ['DATAGOVIN_API_KEY']
@st.cache(allow_output_mutation=True,suppress_st_warning=True)
def getDataGovAdaptor(): 
    return DataGovIndia(API_KEY)

datagovin = getDataGovAdaptor()
result = datagovin.search(description="Wheat",max_results=1,print_results=True)

Here's the output:

bug3

Hope this solves your issue!

from datagovindia.

hearsid avatar hearsid commented on June 15, 2024

@addypy Thank you for the quick reply, it is working for the first time and then giving this error,
image
I also think and agree that it may be because @st.cache is not able to store the DataGovIndia in memory, I'm also looking for other options to replicate st.cache functionality.

from datagovindia.

addypy avatar addypy commented on June 15, 2024

Not sure if this is useful, but if you can't find an alternative, you could try to wrap multiple arguments in the same function - initiate the class with your key, search for the results, and store the output you need.
All the best!

from datagovindia.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.