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 5 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.
28 changes: 14 additions & 14 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,7 +60,7 @@ 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
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 @@ -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
4 changes: 2 additions & 2 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
18 changes: 9 additions & 9 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 @@ -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 Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 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
2 changes: 1 addition & 1 deletion harmony/logging.py → harmony_service_lib/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import copy

from pythonjsonlogger import jsonlogger
from harmony import message
from harmony_service_lib import message


class HarmonyJsonFormatter(jsonlogger.JsonFormatter):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Utilities for acting on Harmony Messages.

These are a collection of useful routines for validation and interrogation of
harmony Messages.
harmony_service_lib Messages.
"""

from typing import Any, List

from harmony.message import Message
from harmony_service_lib.message import Message


def has_self_consistent_grid(message: Message) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions harmony/s3_stac_io.py → harmony_service_lib/s3_stac_io.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from urllib.parse import urlparse
import boto3
from pystac.stac_io import StacIO, DefaultStacIO
from harmony import util
from harmony import aws
from harmony_service_lib import util
from harmony_service_lib import aws
from os import environ

"""
Expand Down
20 changes: 10 additions & 10 deletions harmony/util.py → harmony_service_lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@

from nacl.secret import SecretBox

from harmony import aws
from harmony import http
from harmony_service_lib import aws
from harmony_service_lib import http
# The following imports are for backwards-compatibility for services
# which import them from `harmony.util`. Though they are not used in
# which import them from `harmony_service_lib.util`. Though they are not used in
# this module, importing them here allows applications to work without
# modifications.
from harmony.exceptions import (HarmonyException, CanceledException, ForbiddenException) # noqa: F401
from harmony.logging import build_logger
from harmony.version import get_version
from harmony_service_lib.exceptions import (HarmonyException, CanceledException, ForbiddenException) # noqa: F401
from harmony_service_lib.logging import build_logger
from harmony_service_lib.version import get_version


DEFAULT_SHARED_SECRET_KEY = '_THIS_IS_MY_32_CHARS_SECRET_KEY_'
Expand Down Expand Up @@ -370,7 +370,7 @@ def stage(local_filename, remote_filename, mime, logger=None, location=None, cfg
An s3:// URL to the staged file
"""
# The implementation of this function has been moved to the
# harmony.aws module.
# harmony_service_lib.aws module.
if cfg is None:
cfg = config()
if logger is None:
Expand Down Expand Up @@ -401,7 +401,7 @@ def receive_messages(queue_url, visibility_timeout_s=600, logger=None, cfg=None)
and the contents of the message
"""
# The implementation of this function has been moved to the
# harmony.aws module.
# harmony_service_lib.aws module.
if cfg is None:
cfg = config()
if logger is None:
Expand All @@ -426,7 +426,7 @@ def delete_message(queue_url, receipt_handle, cfg=None):
The configuration values for this runtime environment.
"""
# The implementation of this function has been moved to the
# harmony.aws module.
# harmony_service_lib.aws module.
if cfg is None:
cfg = config()
return aws.delete_message(cfg, queue_url, receipt_handle)
Expand All @@ -449,7 +449,7 @@ def change_message_visibility(queue_url, receipt_handle, visibility_timeout_s, c
The configuration values for this runtime environment.
"""
# The implementation of this function has been moved to the
# harmony.aws module.
# harmony_service_lib.aws module.
if cfg is None:
cfg = config()
return aws.change_message_visibility(cfg, queue_url, receipt_handle, visibility_timeout_s)
Expand Down
4 changes: 2 additions & 2 deletions harmony/version.py → harmony_service_lib/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import harmony
import harmony_service_lib


def get_version():
Expand All @@ -10,4 +10,4 @@ def get_version():
string
A string representing the current version.
"""
return harmony.__version__
return harmony_service_lib.__version__
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ readme = "README.md"
requires-python = ">= 3.8"

[project.scripts]
harmony-service-lib = "harmony.cli.__main__:main"
harmony-service-lib = "harmony_service_lib.cli.__main__:main"

[project.urls]
Homepage = "https://github.com/nasa/harmony-service-lib-py"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
optional-dependencies = {dev = {file = ["dev-requirements.txt"]}}
# Will read __version__ from harmony.__init__.py
version = {attr = "harmony.__version__"}
# Will read __version__ from harmony_service_lib.__init__.py
version = {attr = "harmony_service_lib.__version__"}

[tool.setuptools.packages.find]
exclude = ["contrib", "docs", "tests*"]
Loading
Loading