cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Use OF API from package enerbitdso 0.1.8 PYPI

Colombia
New Contributor II

Hello! I have code to use an API supplied in the energitdso package (This is the repository https://pypi.org/project/enerbitdso/). I changed the code adapting it to AZURE DATABRICKS in python, but although there is a connection with the API, it does not return results. This is my code: 

# Instalar enerbitdso (asegรบrese de que esto se ejecuta sin errores)
%pip install enerbitdso

# Importar librerรญas
import os
from dotenv import load_dotenv

# Ruta relativa al archivo .env
env_file_path = "./.env"

# Cargar las variables de entorno desde el archivo .env
load_dotenv(env_file_path)

# Acceder a las variables de entorno
api_base_url = os.getenv("ENERBIT_API_BASE_URL")
api_username = os.getenv("ENERBIT_API_USERNAME")
api_password = os.getenv("ENERBIT_API_PASSWORD")

# Mostrar las variables de entorno (para verificar la carga correcta)
print(f"API Base URL: {api_base_url}")
print(f"API Username: {api_username}")
print(f"API Password: {api_password}")  # **Nota:** Evite compartir credenciales reales en el cรณdigo

# Ejecutar la consulta de uso de enerbitdso
# Asegรบrese de tener los permisos necesarios para los cรณdigos FRT especificados
!enerbitdso usages fetch Frt08942 Frt46756 Frt47799
2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @Colombia

To execute a notebook in Azure Databricks programmatically and retrieve its results, you can use the Jobs REST API. Hereโ€™s how it works:

  • Create a new job (using the notebook_task parameter) or create a single run (also called RunSubmit) for the notebook.
  • Youโ€™ll receive a run ID, which you can use to track the jobโ€™s progress.
  • Wait until the job is finished (check the state via the get run API until it reaches the TERMINATED state).
  • Retrieve the output of the run.
  • If youโ€™re calling a notebook from an external Python script, consider using dbutils within the notebook itself.
  • Ensure that you have the necessary permissions for the specified FRT codes in your query.

Good luck, and feel free to reach out if you need further assistance! ๐Ÿ˜Š

Colombia
New Contributor II

The owner of the package updated it to use the time out as a parameter of up to 20 seconds and updated a dependent package in DataBricks, with the above the problem was solved

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!