question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ways to import `PrometheusConnect` without also importing **huge** pandas and matplotlib

See original GitHub issue

Is your feature request related to a problem? Please describe.

I found this simple import

from prometheus_api_client import PrometheusConnect

not only import PrometheusConnect itself, but also pandas and possibly matplotlib, which take about 50MB more unnecessary memory when I don’t want to use DataFrames and plot them.

Is there any way to only import PrometheusConnect without also importing huge pandas and matplotlib?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
chauhankaranrajcommented, Dec 23, 2021

not only import PrometheusConnect itself, but also pandas and possibly matplotlib, which take about 50MB more unnecessary memory when I don’t want to use DataFrames and plot them.

Hi @thetaprimeprime, that’s an great observation! I did some memory profiling and can confirm that the additional pandas and matplotlib imports do indeed increase the memory usage by about ~45MB.

Is there any way to only import PrometheusConnect without also importing huge pandas and matplotlib?

At the moment, I don’t think so. But I believe this would be a nice and welcome improvement πŸ˜ƒ Is this something you’d like to work on, or would you rather someone from our team do it?

One way to accomplish this could be to refactor this python module into submodules, something like this:

prometheus_api_client
β”œβ”€β”€ core
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── prometheus_connect.py
β”œβ”€β”€ exceptions
β”‚   β”œβ”€β”€ base_exception.py
β”‚   └── __init__.py
β”œβ”€β”€ __init__.py --> only import core.* here, to avoid importing mpl, pandas
β”œβ”€β”€ parsers
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ metric.py
β”‚   β”œβ”€β”€ metric_range_df.py
β”‚   β”œβ”€β”€ metrics_list.py
β”‚   └── metric_snapshot_df.py
└── utils
    β”œβ”€β”€ datetime_utils.py
    β”œβ”€β”€ __init__.py
    └── print_utils.py

Just a suggestion off the top of my head, we should explore other ideas as well.

/cc @4n4nd

0reactions
seshetacommented, May 22, 2022

@sesheta: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips & tricks to import data into Pandas from various ... - Medium
Pandas library has cemented its place in the Data Science world. This article shows ways to import data into Pandas from different dataΒ ......
Read more >
Importing Data into pandas - DataCamp
Learn how to load and import web data formats such as JSON & HTML into pandas DataFrames. Follow our tutorial and code examples...
Read more >
Python Data Analysis with Pandas and Matplotlib - Coding Club
Learn how to filter data in a Pandas DataFrame; Learn how to read and sort data from a file; Understand the basics of...
Read more >
How to handle large datasets in Python with Pandas and Dask
Now let's have a look at what kind of data we have here and import it into the dataframe. The very first memory...
Read more >
10 minutes to pandas β€” pandas 1.5.2 documentation
This is a short introduction to pandas, geared mainly for new users. You can see more complex recipes in the Cookbook. Customarily, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found