Skip to content

Commit 3caf4e1

Browse files
committed
clean up code
1 parent 09280fa commit 3caf4e1

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

examples/data_usage.ipynb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"outputs": [],
2222
"source": [
2323
"import geoengine as ge\n",
24-
"import matplotlib.pyplot as plt"
24+
"import matplotlib.pyplot as plt\n",
25+
"import pandas as pd"
2526
]
2627
},
2728
{
@@ -310,7 +311,18 @@
310311
}
311312
],
312313
"source": [
313-
"ge.plot_data_usage_summary(ge.UsageSummaryGranularity.MINUTES)"
314+
"df = ge.data_usage_summary(ge.UsageSummaryGranularity.MINUTES)\n",
315+
"df['timestamp'] = pd.to_datetime(df['timestamp']).dt.tz_localize(None)\n",
316+
"\n",
317+
"pivot_df = df.pivot(index='timestamp', columns='data', values='count').fillna(0)\n",
318+
"pivot_df.plot(kind='bar', figsize=(10, 6))\n",
319+
"\n",
320+
"plt.title('Data Usage by Data over time')\n",
321+
"plt.xlabel('Timestamp')\n",
322+
"plt.ylabel('Count')\n",
323+
"plt.xticks(rotation=45)\n",
324+
"plt.legend(title='Data')\n",
325+
"plt.show()"
314326
]
315327
},
316328
{

geoengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from .util import clamp_datetime_ms_ns
3434
from .workflow import WorkflowId, Workflow, workflow_by_id, register_workflow, get_quota, update_quota, data_usage, \
35-
data_usage_summary, plot_data_usage_summary
35+
data_usage_summary
3636
from .raster import RasterTile2D
3737
from .raster_workflow_rio_writer import RasterWorkflowRioWriter
3838

geoengine/workflow.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import websockets.client
3030
import xarray as xr
3131
import pyarrow as pa
32-
import matplotlib.pyplot as plt
3332

3433
import geoengine_openapi_client
3534
from geoengine import api
@@ -1007,23 +1006,3 @@ def data_usage_summary(granularity: geoengine_openapi_client.UsageSummaryGranula
10071006
df = pd.DataFrame(usage_dicts)
10081007

10091008
return df
1010-
1011-
1012-
def plot_data_usage_summary(granularity: geoengine_openapi_client.UsageSummaryGranularity,
1013-
data: Optional[str] = None, offset: int = 0, limit: int = 10):
1014-
'''
1015-
Plot data usage summary
1016-
'''
1017-
1018-
df = data_usage_summary(granularity, data, offset, limit)
1019-
df['timestamp'] = pd.to_datetime(df['timestamp']).dt.tz_localize(None)
1020-
1021-
pivot_df = df.pivot(index='timestamp', columns='data', values='count').fillna(0)
1022-
pivot_df.plot(kind='bar', figsize=(10, 6))
1023-
1024-
plt.title('Data Usage by Data over time')
1025-
plt.xlabel('Timestamp')
1026-
plt.ylabel('Count')
1027-
plt.xticks(rotation=45)
1028-
plt.legend(title='Data')
1029-
plt.show()

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package_dir =
1818
packages = find:
1919
python_requires = >=3.9
2020
install_requires =
21-
geoengine-openapi-client @ git+https://github.com/geo-engine/openapi-client@esg-quota#subdirectory=python # TODO update when merged
21+
geoengine-openapi-client == 0.0.18
2222
geopandas >=0.9,<0.15
2323
matplotlib >=3.5,<3.8
2424
numpy >=1.21,<2

0 commit comments

Comments
 (0)