Skip to content

Commit

Permalink
ready for firms ingest - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jul 16, 2024
1 parent da8f888 commit de33870
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 48 deletions.
2 changes: 1 addition & 1 deletion blue_geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DESCRIPTION = f"{ICON} AI for precise geospatial data analysis and visualization."

VERSION = "4.47.1"
VERSION = "4.48.1"

REPO_NAME = "blue-geo"

Expand Down
8 changes: 4 additions & 4 deletions blue_geo/firms/api/area/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
parser.add_argument(
"--source",
type=str,
default=Source.default.name,
help="|".join(Source.default.values),
default=Source.default().name,
help="|".join(Source.values()),
)
parser.add_argument(
"--area",
type=str,
default=Area.default.name,
help="|".join(Area.default.values),
default=Area.default().name,
help="|".join(Area.values()),
)
parser.add_argument(
"--date",
Expand Down
16 changes: 12 additions & 4 deletions blue_geo/firms/api/area/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class APIRequest:
def __init__(
self,
source: Source = Source.default,
area: Area = Area.default,
source: Source = Source.default(),
area: Area = Area.default(),
date: str = "",
day_range: int = 1,
log: bool = True,
Expand Down Expand Up @@ -38,8 +38,16 @@ def as_str(self) -> str:
self.source.description,
)

def ingest(object_name: str) -> bool:
logger.info(f"πŸͺ„ -> {object_name}")
def ingest(self, object_name: str) -> bool:
logger.info(
"{}.{} -> {}".format(
NAME,
self.__class__.__name__,
object_name,
)
)

logger.info("πŸͺ„")

return True

Expand Down
16 changes: 8 additions & 8 deletions blue_geo/firms/api/area/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class Area(Enum):
WEST = auto()
WORLD = auto()

@property
def default():
@classmethod
def default(cls):
return Area.WORLD

@property
def values():
@classmethod
def values(cls):
return [area.name.lower() for area in Area]


Expand Down Expand Up @@ -50,10 +50,10 @@ class Source(Enum):
def __init__(self, _, description):
self.description = description

@property
def default():
@classmethod
def default(cls):
return Source.MODIS_NRT

@property
def values():
@classmethod
def values(cls):
return [source.name for source in Source]
4 changes: 2 additions & 2 deletions blue_geo/tests/test_firms_api_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
["area", "source"],
[
[
enums.Area.default,
enums.Source.default,
enums.Area.default(),
enums.Source.default(),
],
],
)
Expand Down
42 changes: 13 additions & 29 deletions notebooks/firms-area-api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
"name": "stderr",
"output_type": "stream",
"text": [
"🌐 abcli-9.163.1, built on 15 July 2024, 20:45:12\n"
"🌐 abcli-9.163.1, built on 15 July 2024, 21:43:51\n"
]
}
],
"source": [
"from abcli import fullname\n",
"from abcli import string\n",
"from abcli.modules import objects\n",
"from abcli.plugins import seed\n",
"from blue_geo.firms.api.area.classes import APIRequest\n",
"from blue_geo.logger import logger\n",
"\n",
Expand All @@ -50,27 +49,9 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🌐 blue_geo.firms.api.area.APIRequest, area:world, source: MODIS_NRT (MODIS Near Real-Time, Real-Time and Ultra Real-Time)\n"
]
}
],
"source": [
"api_request = APIRequest()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"object_name = f\"firms-{string.timestamp()}\"\n",
"object_path = objects.object_path(object_name)"
"object_name = f\"firms-{string.timestamp()}\""
]
},
{
Expand All @@ -83,19 +64,22 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🌐 Hello World! πŸͺ„\n"
"🌐 blue_geo.firms.api.area.APIRequest, area:world, source: MODIS_NRT (MODIS Near Real-Time, Real-Time and Ultra Real-Time)\n",
"🌐 blue_geo.firms.api.area.APIRequest -> firms-2024-07-15-21-43-51-94618\n",
"🌐 πŸͺ„\n"
]
}
],
"source": [
"logger.info(\"Hello World! πŸͺ„\")"
"api_request = APIRequest()\n",
"assert api_request.ingest(object_name)"
]
},
{
Expand All @@ -108,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -121,15 +105,15 @@
"\u001b[0;36mπŸ“œ awesome-bash-cli: abcli/config.env: 13 env var(s)\u001b[0m\n",
"\u001b[0;36mπŸ”‹ gpu: not found.\u001b[0m\n",
"\u001b[0;36mπŸš€ abcli-9.163.1.current\u001b[0m\n",
"\u001b[0;36mconfirmed: firms-2024-07-15-20-45-12-54457 does not exist.\u001b[0m\n",
"\u001b[0;36mfirms-2024-07-15-20-45-12-54457 open upload started.\u001b[0m\n"
"\u001b[0;36mconfirmed: firms-2024-07-15-21-43-51-94618 does not exist.\u001b[0m\n",
"\u001b[0;36mfirms-2024-07-15-21-43-51-94618 open upload started.\u001b[0m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
":: firms-2024-07-15-20-45-12-54457 += #open.\n"
":: firms-2024-07-15-21-43-51-94618 += #open.\n"
]
}
],
Expand All @@ -144,7 +128,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit de33870

Please sign in to comment.