Showing results for 
Search instead for 
Did you mean: 
Machine Learning
Showing results for 
Search instead for 
Did you mean: 

Use OF API from package enerbitdso 0.1.8 PYPI

New Contributor II

Hello! I have code to use an API supplied in the energitdso package (This is the repository 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

# 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

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! 😊

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