Skip to content

Commit

Permalink
Rename astrodb_scripts to astrodb_utils (#485)
Browse files Browse the repository at this point in the history
* astrodb_scripts -> astrodb_utils name change and updates
  • Loading branch information
kelle authored Mar 13, 2024
1 parent da38446 commit e419082
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gen-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- git+https://github.com/astrodbtoolkit/astrodb_utils.git@main
2 changes: 1 addition & 1 deletion simple/utils/astrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion simple/utils/companions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import sqlalchemy.exc
from astrodb_scripts import (
from astrodb_utils import (
AstroDBError,
)

Expand Down
13 changes: 7 additions & 6 deletions simple/utils/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion simple/utils/spectral_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/scheduled_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 5 additions & 6 deletions tests/test_spectra_utils.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit e419082

Please sign in to comment.