diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 890237a05..791651152 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,7 @@ "forwardPorts": [5432], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip install astrodbkit2 pytest psycopg2 ads git+https://github.com/astrodbtoolkit/astrodb_scripts.git@main", + "postCreateCommand": "pip install astrodbkit2 pytest psycopg2 ads git+https://github.com/astrodbtoolkit/astrodb_utils.git@main", // python scripts/tutorials/generate_database.py sqlite // python scripts/tutorials/generate_database.py postgres postgres://postgres@localhost:5432 diff --git a/.github/workflows/gen-db.yml b/.github/workflows/gen-db.yml index cba6d4cbf..0284fb0ae 100644 --- a/.github/workflows/gen-db.yml +++ b/.github/workflows/gen-db.yml @@ -30,7 +30,7 @@ jobs: run: | python -m pip install --upgrade pip pip install astrodbkit2 - pip install git+https://github.com/astrodbtoolkit/astrodb_scripts.git@main + pip install git+https://github.com/astrodbtoolkit/astrodb_utils.git@main - name: Generate sqlite (file) database run: | diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index fa6943186..05cbf5514 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,7 +26,7 @@ jobs: python -m pip install --upgrade pip pip install pytest ads matplotlib pip install astrodbkit2 - pip install git+https://github.com/astrodbtoolkit/astrodb_scripts.git@main + pip install git+https://github.com/astrodbtoolkit/astrodb_utils.git@main - name: Test with pytest run: | diff --git a/.github/workflows/scheduled-tests.yml b/.github/workflows/scheduled-tests.yml index 97ac034ac..8473c7230 100644 --- a/.github/workflows/scheduled-tests.yml +++ b/.github/workflows/scheduled-tests.yml @@ -26,7 +26,7 @@ jobs: python -m pip install --upgrade pip pip install pytest ads pip install astrodbkit2 - pip install git+https://github.com/astrodbtoolkit/astrodb_scripts.git@main + pip install git+https://github.com/astrodbtoolkit/astrodb_utils.git@main - name: Test with pytest run: | diff --git a/environment.yml b/environment.yml index 8b65afed3..017ecb35e 100644 --- a/environment.yml +++ b/environment.yml @@ -75,4 +75,4 @@ dependencies: - webencodings==0.5.1 - werkzeug==2.2.2 - zipp==3.13.0 - - git+https://github.com/astrodbtoolkit/astrodb_scripts.git@main \ No newline at end of file + - git+https://github.com/astrodbtoolkit/astrodb_utils.git@main \ No newline at end of file diff --git a/simple/utils/astrometry.py b/simple/utils/astrometry.py index 66b09aaa1..6557c2c59 100644 --- a/simple/utils/astrometry.py +++ b/simple/utils/astrometry.py @@ -2,7 +2,7 @@ import logging from sqlalchemy import and_ import sqlalchemy.exc -from astrodb_scripts import ( +from astrodb_utils import ( AstroDBError, find_source_in_db, ) diff --git a/simple/utils/companions.py b/simple/utils/companions.py index 983e820b1..e727492e1 100644 --- a/simple/utils/companions.py +++ b/simple/utils/companions.py @@ -1,6 +1,6 @@ import logging import sqlalchemy.exc -from astrodb_scripts import ( +from astrodb_utils import ( AstroDBError, ) diff --git a/simple/utils/spectra.py b/simple/utils/spectra.py index 666296098..d22344782 100644 --- a/simple/utils/spectra.py +++ b/simple/utils/spectra.py @@ -14,10 +14,10 @@ from specutils import Spectrum1D from astrodbkit2.astrodb import Database -from astrodb_scripts import ( +from astrodb_utils import ( AstroDBError, find_source_in_db, - check_internet_connection, + internet_connection, find_publication, ) @@ -190,7 +190,7 @@ def ingest_spectrum( else: return flags else: - good_reference = find_publication(db, reference) + good_reference = find_publication(db, reference=reference) if good_reference[0] is False: msg = ( f"Spectrum for {source} could not be added to the database because the " @@ -219,7 +219,7 @@ def ingest_spectrum( # Check if spectrum file is accessible # First check for internet - internet = check_internet_connection() + internet = internet_connection() if internet: request_response = requests.head(spectrum) status_code = ( @@ -466,7 +466,8 @@ def spectrum_plottable(spectrum_path, raise_error=True, show_plot=False): return False except u.UnitConversionError as e: msg = ( - e + f"Skipping {spectrum_path}: unable to convert spectral axis to microns" + f"{str(e)} \n" + f"Skipping {spectrum_path}: unable to convert spectral axis to microns" ) if raise_error: logger.error(msg) @@ -475,7 +476,7 @@ def spectrum_plottable(spectrum_path, raise_error=True, show_plot=False): logger.warning(msg) return False except ValueError as e: - msg = e + f"Skipping {spectrum_path}: Value error" + msg = f"{str(e)} \nSkipping {spectrum_path}: Value error" if raise_error: logger.error(msg) raise AstroDBError(msg) diff --git a/simple/utils/spectral_types.py b/simple/utils/spectral_types.py index 218007d3b..71df34e08 100644 --- a/simple/utils/spectral_types.py +++ b/simple/utils/spectral_types.py @@ -3,7 +3,7 @@ import logging from sqlalchemy import and_ import sqlalchemy.exc -from astrodb_scripts import ( +from astrodb_utils import ( AstroDBError, find_source_in_db, ) diff --git a/tests/conftest.py b/tests/conftest.py index bb0fa632d..aca111072 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,9 +3,9 @@ import sys import logging from astrodbkit2.astrodb import create_database, Database -sys.path.append("./simple") -# from schema import REFERENCE_TABLES -from schema import * +sys.path.append("./") +from simple.schema import REFERENCE_TABLES +from simple.schema import * logger = logging.getLogger("AstroDB") diff --git a/tests/scheduled_checks.py b/tests/scheduled_checks.py index 16ab36a1b..0d7bf1d3a 100644 --- a/tests/scheduled_checks.py +++ b/tests/scheduled_checks.py @@ -4,11 +4,11 @@ import requests from tqdm import tqdm from astrodbkit2.astrodb import create_database, Database -from astrodb_scripts import check_internet_connection +from astrodb_utils.utils import check_internet_connection sys.path.append(".") -from schema.schema import * -from . import REFERENCE_TABLES +from simple.schema import * +from simple.schema import REFERENCE_TABLES DB_NAME = "temp.sqlite" diff --git a/tests/test_spectra_utils.py b/tests/test_spectra_utils.py index 82619fbc1..a8eead2eb 100644 --- a/tests/test_spectra_utils.py +++ b/tests/test_spectra_utils.py @@ -1,11 +1,8 @@ # temp_db and logger is defined in conftest.py import pytest -import sys -from astrodb_scripts.utils import ( +from astrodb_utils.utils import ( AstroDBError, ) - -sys.path.append("./") from simple.utils.spectra import ( ingest_spectrum, # ingest_spectrum_from_fits, @@ -194,7 +191,8 @@ def test_ingest_spectrum_errors(temp_db): ) # : astropy.io.fits uses zero-based indexing. @pytest.mark.filterwarnings("ignore:'datfix' made the change 'Set MJD-OBS to") @pytest.mark.filterwarnings( - "ignore:'erg/cm2/s/A' contains multiple slashes, which is discouraged by the FITS standard" + "ignore:'erg/cm2/s/A' contains multiple slashes," + " which is discouraged by the FITS standard" ) @pytest.mark.filterwarnings("ignore") def test_ingest_spectrum_works(temp_db): @@ -221,7 +219,8 @@ def test_ingest_spectrum_works(temp_db): @pytest.mark.filterwarnings( "ignore", message=( - "'erg/cm2/s/A' contains multiple slashes, which is discouraged by the FITS standard.*", + "'erg/cm2/s/A' contains multiple slashes, " + "which is discouraged by the FITS standard.*", ), ) @pytest.mark.filterwarnings("ignore") diff --git a/tests/test_utils.py b/tests/test_utils.py index f60ded102..22c492954 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,9 +1,10 @@ import pytest import sys from astropy.table import Table -from astrodb_scripts.utils import ( +from astrodb_utils.utils import ( AstroDBError, ) + sys.path.append("./") from simple.utils.spectral_types import ( convert_spt_string_to_code,