Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename package from harmony to harmony_service_lib #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 120
per-file-ignores = harmony/__init__.py:F401
per-file-ignores = harmony_service_lib/__init__.py:F401
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REPO_USER ?= __token__
REPO_PASS ?= unset

version:
sed -i.bak "s/__version__ .*/__version__ = \"$(VERSION)\"/" harmony/__init__.py && rm harmony/__init__.py.bak
sed -i.bak "s/__version__ .*/__version__ = \"$(VERSION)\"/" harmony_service_lib/__init__.py && rm harmony_service_lib/__init__.py.bak

build: clean version
python -m pip install --upgrade --quiet setuptools wheel twine build
Expand All @@ -27,13 +27,13 @@ install:
pip install -r requirements.txt

lint:
flake8 harmony
flake8 harmony_service_lib

test:
pytest --cov=harmony tests
pytest --cov=harmony_service_lib tests

test-no-warnings:
pytest --disable-warnings --cov=harmony tests
pytest --disable-warnings --cov=harmony_service_lib tests

# HARMONY-1908 - Ignore jinja2 vulnerability (safety ID 70612)
cve-check:
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ python-language-server ~= 0.35
responses ~=0.22.0
pycodestyle >= 2.9.1
safety ~= 3.2.7
setuptools == 70.0.0
setuptools == 70.0.0
12 changes: 6 additions & 6 deletions example/example_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
from tempfile import mkdtemp
from pystac import Asset

import harmony
from harmony.util import generate_output_filename, stage, download
import harmony_service_lib
from harmony_service_lib.util import generate_output_filename, stage, download

# IMPORTANT: The following line avoids making real calls to a non-existent
# Harmony frontend. Service authors should not set this variable to "dev"
# or "test" when releasing the service.
os.environ['ENV'] = 'dev'


class ExampleAdapter(harmony.BaseHarmonyAdapter):
class ExampleAdapter(harmony_service_lib.BaseHarmonyAdapter):
"""
Shows an example of what a service adapter implementation looks like
"""
Expand Down Expand Up @@ -115,12 +115,12 @@ def main():
"""
parser = argparse.ArgumentParser(prog='example', description='Run an example service')

harmony.setup_cli(parser)
harmony_service_lib.setup_cli(parser)

args = parser.parse_args()

if (harmony.is_harmony_cli(args)):
harmony.run_cli(parser, args, ExampleAdapter)
if (harmony_service_lib.is_harmony_cli(args)):
harmony_service_lib.run_cli(parser, args, ExampleAdapter)
else:
run_cli(args)

Expand Down
File renamed without changes.
34 changes: 17 additions & 17 deletions harmony/adapter.py → harmony_service_lib/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from deprecation import deprecated
from pystac import Catalog, Item, Asset, read_file

from harmony.exceptions import CanceledException
from harmony.http import request_context
from harmony.logging import build_logger
from harmony.message import Temporal
from harmony.util import touch_health_check_file
from harmony_service_lib.exceptions import CanceledException
from harmony_service_lib.http import request_context
from harmony_service_lib.logging import build_logger
from harmony_service_lib.message import Temporal
from harmony_service_lib.util import touch_health_check_file
from . import util


Expand All @@ -39,7 +39,7 @@ class BaseHarmonyAdapter(ABC):

Attributes
----------
message : harmony.Message
message : harmony_service_lib.Message
The Harmony input which needs acting upon
temp_paths : list
A list of string paths that should be cleaned up on exit
Expand All @@ -60,11 +60,11 @@ def __init__(self, message, catalog=None, config=None):

Parameters
----------
message : harmony.Message
message : harmony_service_lib.Message
The Harmony input which needs acting upon
catalog : pystac.Catalog
A STAC catalog containing the files on which to act
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration values for this runtime environment.
"""
if catalog is None:
Expand Down Expand Up @@ -111,7 +111,7 @@ def invoke(self):

Returns
-------
(harmony.Message, pystac.Catalog | list)
(harmony_service_lib.Message, pystac.Catalog | list)
A tuple of the Harmony message, with any processed fields marked as such and
in this implementation, a single STAC catalog describing the output.
(Services overriding this method may return a list of STAC catalogs if desired.)
Expand Down Expand Up @@ -248,7 +248,7 @@ def process_item(self, item, source):
----------
item : pystac.Item
the item that should be processed
source : harmony.message.Source
source : harmony_service_lib.message.Source
the input source defining the variables, if any, to subset from the item

Returns
Expand Down Expand Up @@ -279,7 +279,7 @@ def _get_item_source(self, item):

Returns
-------
harmony.message.Source
harmony_service_lib.message.Source
The source of the input item
"""
parent = item
Expand Down Expand Up @@ -319,7 +319,7 @@ def download_granules(self, granules=None):
Parameters
----------
granules : list
A list of harmony.message.Granule objects corresponding to the granules to download. Default:
A list of harmony_service_lib.message.Granule objects corresponding to the granules to download. Default:
all granules in the incoming message
"""
temp_dir = mkdtemp()
Expand Down Expand Up @@ -420,7 +420,7 @@ def completed_with_redirect(
The mime type of the file, by default the output mime type requested by Harmony
title : string, optional
Textual information to provide users along with the link
temporal : harmony.message.Temporal, optional
temporal : harmony_service_lib.message.Temporal, optional
The temporal extent of the provided file. If not provided, the source granule's
temporal will be used when a source granule is provided
bbox : list, optional
Expand Down Expand Up @@ -480,7 +480,7 @@ def completed_with_local_file(
The mime type of the file, by default the output mime type requested by Harmony
title : string, optional
Textual information to provide users along with the link
temporal : harmony.message.Temporal, optional
temporal : harmony_service_lib.message.Temporal, optional
The temporal extent of the provided file. If not provided, the source granule's
temporal will be used when a source granule is provided
bbox : list, optional
Expand Down Expand Up @@ -538,7 +538,7 @@ def async_add_local_file_partial_result(
The mime type of the file, by default the output mime type requested by Harmony
progress : integer, optional
Numeric progress of the total request, 0-100
temporal : harmony.message.Temporal, optional
temporal : harmony_service_lib.message.Temporal, optional
The temporal extent of the provided file. If not provided, the source granule's
temporal will be used when a source granule is provided
bbox : list, optional
Expand Down Expand Up @@ -576,7 +576,7 @@ def async_add_url_partial_result(self, url, title=None, mime=None, progress=None
source_granule : message.Granule, optional
The granule from which the file was derived, if it was derived from a single granule. This
will be used to produce a canonical filename and assist when temporal and bbox are not specified
temporal : harmony.message.Temporal, optional
temporal : harmony_service_lib.message.Temporal, optional
The temporal extent of the provided file. If not provided, the source granule's
temporal will be used when a source granule is provided
bbox : list, optional
Expand Down Expand Up @@ -698,7 +698,7 @@ def _build_callback_item_params(
source_granule : message.Granule, optional
The granule from which the file was derived, if it was derived from a single granule. This
will be used to produce a canonical filename and assist when temporal and bbox are not specified
temporal : harmony.message.Temporal, optional
temporal : harmony_service_lib.message.Temporal, optional
The temporal extent of the provided file. If not provided, the source granule's
temporal will be used when a source granule is provided
bbox : list, optional
Expand Down
16 changes: 8 additions & 8 deletions harmony/aws.py → harmony_service_lib/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
This module includes various AWS-specific functions to stage data in S3 and deal with
messages in SQS queues.

This module relies on the harmony.util.config and its environment variables to be
This module relies on the harmony_service_lib.util.config and its environment variables to be
set for correct operation. See that module and the project README for details.
"""
from urllib.parse import urlparse
from os import environ
import boto3
from botocore.config import Config
from harmony import util
from harmony_service_lib import util


def is_s3(url: str) -> bool:
Expand Down Expand Up @@ -73,7 +73,7 @@ def _get_aws_client(config, service, user_agent=None):

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
service : string
The AWS service name for which to construct a client, e.g. "s3" or "sqs"
Expand All @@ -97,7 +97,7 @@ def download(config, url, destination_file, user_agent=None):

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
destination_file : file-like
The destination file where the object will be written. Must be
Expand All @@ -122,7 +122,7 @@ def stage(config, local_filename, remote_filename, mime, logger, location=None):

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
local_filename : string
A path and filename to the local file that should be staged
Expand Down Expand Up @@ -171,7 +171,7 @@ def receive_messages(config, queue_url, visibility_timeout_s, logger):

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
queue_url : string
The URL of the queue to receive messages on
Expand Down Expand Up @@ -212,7 +212,7 @@ def delete_message(config, queue_url, receipt_handle):

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
queue_url : string
The queue from which the message originated
Expand All @@ -229,7 +229,7 @@ def change_message_visibility(config, queue_url, receipt_handle, visibility_time

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
queue_url : string
The queue from which the message originated
Expand Down
26 changes: 13 additions & 13 deletions harmony/cli.py → harmony_service_lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
from pystac import Catalog, CatalogType
from pystac.layout import BestPracticesLayoutStrategy

from harmony.exceptions import CanceledException, HarmonyException
from harmony.message import Message
from harmony.logging import setup_stdout_log_formatting, build_logger
from harmony.util import (receive_messages, delete_message, change_message_visibility,
config, create_decrypter)
from harmony.version import get_version
from harmony.aws import is_s3, write_s3
from harmony.s3_stac_io import S3StacIO
from harmony_service_lib.exceptions import CanceledException, HarmonyException
from harmony_service_lib.message import Message
from harmony_service_lib.logging import setup_stdout_log_formatting, build_logger
from harmony_service_lib.util import (receive_messages, delete_message, change_message_visibility,
config, create_decrypter)
from harmony_service_lib.version import get_version
from harmony_service_lib.aws import is_s3, write_s3
from harmony_service_lib.s3_stac_io import S3StacIO


class MultiCatalogLayoutStrategy(BestPracticesLayoutStrategy):
Expand Down Expand Up @@ -121,7 +121,7 @@ def _invoke_deprecated(AdapterClass, message_string, config):
The BaseHarmonyAdapter subclass to use to handle service invocations
message_string : string
The Harmony input message
config : harmony.util.Config
config : harmony_service_lib.util.Config
A configuration instance for this service
Returns
-------
Expand Down Expand Up @@ -184,7 +184,7 @@ def _write_error(metadata_dir, message, category='Unknown'):

def _build_adapter(AdapterClass, message_string, sources_path, data_location, config):
"""
Creates the adapter to be invoked for the given harmony input
Creates the adapter to be invoked for the given harmony_service_lib input

Parameters
----------
Expand All @@ -196,7 +196,7 @@ def _build_adapter(AdapterClass, message_string, sources_path, data_location, co
A file location containing a STAC catalog corresponding to the input message sources
data_location : string
The name of the directory where output should be written
config : harmony.util.Config
config : harmony_service_lib.util.Config
A configuration instance for this service
Returns
-------
Expand Down Expand Up @@ -279,7 +279,7 @@ def _start(AdapterClass, queue_url, visibility_timeout_s, config):
visibility_timeout_s : int
The time interval during which the message can't be picked up by other
listeners on the queue.
config : harmony.util.Config
config : harmony_service_lib.util.Config
A configuration instance for this service
"""
for receipt, message in receive_messages(queue_url, visibility_timeout_s, cfg=config):
Expand Down Expand Up @@ -318,7 +318,7 @@ def run_cli(parser, args, AdapterClass, cfg=None):
Argument values parsed from the command line, presumably via ArgumentParser.parse_args
AdapterClass : class
The BaseHarmonyAdapter subclass to use to handle service invocations
cfg : harmony.util.Config
cfg : harmony_service_lib.util.Config
A configuration instance for this service
"""
if cfg is None:
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions harmony/http.py → harmony_service_lib/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
federated token authentication. It includes an optional fallback authentication that
uses an EDL user to download data when the feature is enabled.

This module relies on the harmony.util.config and its environment variables to be
This module relies on the harmony_service_lib.util.config and its environment variables to be
set for correct operation. See that module and the project README for details.
"""

Expand All @@ -21,9 +21,9 @@

import requests

from harmony.earthdata import EarthdataAuth, EarthdataSession
from harmony.exceptions import ServerException, ForbiddenException
from harmony.logging import build_logger
from harmony_service_lib.earthdata import EarthdataAuth, EarthdataSession
from harmony_service_lib.exceptions import ServerException, ForbiddenException
from harmony_service_lib.logging import build_logger

# Timeout in seconds. Per requests docs, this is not a time limit on
# the entire response download; rather, an exception is raised if the
Expand Down Expand Up @@ -183,7 +183,7 @@ def _download(

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
url : str
The url for the resource to download
Expand Down Expand Up @@ -272,7 +272,7 @@ def _download_with_fallback_authn(config, url: str, data, user_agent=None, **kwa

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
url : str
The url for the resource to download
Expand Down Expand Up @@ -358,7 +358,7 @@ def download(config, url: str, access_token: str, data, destination_file,

Parameters
----------
config : harmony.util.Config
config : harmony_service_lib.util.Config
The configuration for the current runtime environment.
url : str
The url for the resource to download
Expand Down
Loading
Loading