Skip to content

Commit

Permalink
updated logic for active and latest hurricanes feature in es index (E…
Browse files Browse the repository at this point in the history
…CCC-MSC#350)

visual changes to code

removing trailing commas

Co-authored-by: Louis-Philippe Rousseau Lambert <[email protected]>
  • Loading branch information
RousseauLambertLP and Louis-Philippe Rousseau Lambert authored Aug 9, 2024
1 parent 2e9b3a8 commit 5ec6792
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 33 deletions.
7 changes: 5 additions & 2 deletions debian/msc-pygeoapi.cron.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ MAILTO=""
# every day at 0700h, clean metnotes data older than 7 days
0 7 * * * geoadm . /local/home/geoadm/.profile && msc-pygeoapi data metnotes clean-indexes --days 7 --yes

# every day at 0800h clean hurricanes data older than 7 days
0 8 * * * geoadm . /local/home/geoadm/.profile && msc-pygeoapi data hurricanes clean-indexes --days 7 --dataset all --yes
# every day at 0800h clean hurricanes data older than 30 days
0 8 * * * geoadm . /local/home/geoadm/.profile && msc-pygeoapi data hurricanes clean-indexes --days 30 --dataset all --yes

# every hour update hurricanes active status (48 hours from publication datetime)
0 * * * * geoadm . /local/home/geoadm/.profile && msc-pygeoapi data hurricanes update-active-status -h 48

# every day at 0300h, clean out empty MetPX directories
0 3 * * * geoadm . /local/home/geoadm/.profile && /usr/bin/find $MSC_PYGEOAPI_CACHEDIR -type d -empty -delete > /dev/null 2>&1
Expand Down
33 changes: 22 additions & 11 deletions msc_pygeoapi/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def OPTION_DATASET(*args, **kwargs):

default_kwargs = {
'required': True,
'help': 'Dataset to load, or all if loading everything',
'help': 'Dataset to load, or all if loading everything'
}

if not args:
Expand All @@ -52,7 +52,7 @@ def OPTION_DATASET(*args, **kwargs):
def OPTION_DAYS(**kwargs):

default_kwargs = {
'type': int,
'type': int
}

kwargs = {**default_kwargs, **kwargs} if kwargs else default_kwargs
Expand All @@ -66,7 +66,7 @@ def OPTION_DB(*args, **kwargs):

default_kwargs = {
'required': True,
'help': 'Database connection string',
'help': 'Database connection string'
}

if not args:
Expand All @@ -84,7 +84,7 @@ def OPTION_DIRECTORY(*args, **kwargs):
default_kwargs = {
'type': click.Path(exists=True, resolve_path=True),
'required': False,
'help': 'Path to directory',
'help': 'Path to directory'
}

if not args:
Expand All @@ -100,7 +100,7 @@ def OPTION_ELASTICSEARCH(*args, **kwargs):
default_args = ['--es']

default_kwargs = {
'help': 'URL to Elasticsearch',
'help': 'URL to Elasticsearch'
}

if not args:
Expand All @@ -116,7 +116,7 @@ def OPTION_ES_PASSWORD(*args, **kwargs):
default_args = ['--password']

default_kwargs = {
'help': 'Password to connect to Elasticsearch',
'help': 'Password to connect to Elasticsearch'
}

if not args:
Expand All @@ -132,7 +132,7 @@ def OPTION_ES_USERNAME(*args, **kwargs):
default_args = ['--username']

default_kwargs = {
'help': 'Username to connect to Elasticsearch',
'help': 'Username to connect to Elasticsearch'
}

if not args:
Expand Down Expand Up @@ -162,7 +162,7 @@ def OPTION_FILE(*args, **kwargs):
default_kwargs = {
'type': click.Path(exists=True, resolve_path=True),
'required': False,
'help': 'Path to file',
'help': 'Path to file'
}

if not args:
Expand All @@ -173,12 +173,23 @@ def OPTION_FILE(*args, **kwargs):
return click.option(*args, **kwargs)


def OPTION_HOURS(**kwargs):

default_kwargs = {
'type': int
}

kwargs = {**default_kwargs, **kwargs} if kwargs else default_kwargs

return click.option('--hours', '-h', **kwargs)


def OPTION_INDEX_NAME(*args, **kwargs):

default_args = ['--index-name', '-i']

default_kwargs = {
'help': 'Elasticsearch index name to delete',
'help': 'Elasticsearch index name to delete'
}

if not args:
Expand Down Expand Up @@ -214,7 +225,7 @@ def OPTION_BATCH_SIZE(*args, **kwargs):
'default': 10000,
'type': click.IntRange(1, 100000),
'required': False,
'help': 'Number of documents to upload at a time to ES index',
'help': 'Number of documents to upload at a time to ES index'
}

if not args:
Expand All @@ -230,7 +241,7 @@ def OPTION_YES(**kwargs):
default_kwargs = {
'is_flag': True,
'callback': click_abort_if_false,
'expose_value': False,
'expose_value': False
}

kwargs = {**default_kwargs, **kwargs} if kwargs else default_kwargs
Expand Down
Loading

0 comments on commit 5ec6792

Please sign in to comment.