-
Notifications
You must be signed in to change notification settings - Fork 93
/
any_env4.py
35 lines (26 loc) · 1.26 KB
/
any_env4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Modify dataset with arbitrary env"""
from h2oaicore.data import CustomData
class FreshEnvData(CustomData):
# Specify the python package dependencies. Will be installed in order of list
# Below caches the env into "id" folder
# isolate_env = dict(pyversion="3.11", install_h2oaicore=False, install_datatable=True, modules_needed_by_name=["pandas==1.5.3"], cache_env=True, id="myrecipe12345")
# Below does not cache the env
isolate_env = dict(pyversion="3.11", install_h2oaicore=False, install_datatable=True,
modules_needed_by_name=["pandas==1.5.3"])
@staticmethod
def create_data(X=None):
import os
import datatable as dt
if X is not None and os.path.isfile(X):
X = dt.fread(X)
else:
X = None
my_path = os.path.dirname(__file__)
import pandas as pd
assert pd.__version__ == "1.1.5", "actual: %s" % pd.__version__
url = "http://data.un.org/_Docs/SYB/CSV/SYB63_226_202009_Net%20Disbursements%20from%20Official%20ODA%20to%20Recipients.csv"
import urllib.request
new_file = os.path.join(my_path, "user_file.csv")
urllib.request.urlretrieve(url, new_file)
import datatable as dt
return dt.fread(new_file)