From ef68e5bbeceac6b7c58d73c47c5a95c6857e16b9 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 11 Sep 2024 11:36:28 -0400 Subject: [PATCH 1/5] Renaming package to be AstrodbKit --- .github/workflows/test-package.yml | 4 +- {astrodbkit2 => astrodbkit}/__init__.py | 0 {astrodbkit2 => astrodbkit}/astrodb.py | 0 {astrodbkit2 => astrodbkit}/schema_example.py | 4 +- {astrodbkit2 => astrodbkit}/spectra.py | 0 {astrodbkit2 => astrodbkit}/tests/__init__.py | 0 .../tests/test_astrodb.py | 6 +- .../tests/test_spectra.py | 2 +- .../tests/test_utils.py | 2 +- .../tests/test_views.py | 2 +- {astrodbkit2 => astrodbkit}/utils.py | 2 +- {astrodbkit2 => astrodbkit}/views.py | 0 docs/astrodb.rst | 2 +- docs/index.rst | 72 +++++++++---------- docs/spectra.rst | 2 +- docs/utils.rst | 2 +- pyproject.toml | 42 +++++------ setup.cfg | 4 +- 18 files changed, 72 insertions(+), 74 deletions(-) rename {astrodbkit2 => astrodbkit}/__init__.py (100%) rename {astrodbkit2 => astrodbkit}/astrodb.py (100%) rename {astrodbkit2 => astrodbkit}/schema_example.py (98%) rename {astrodbkit2 => astrodbkit}/spectra.py (100%) rename {astrodbkit2 => astrodbkit}/tests/__init__.py (100%) rename {astrodbkit2 => astrodbkit}/tests/test_astrodb.py (99%) rename {astrodbkit2 => astrodbkit}/tests/test_spectra.py (99%) rename {astrodbkit2 => astrodbkit}/tests/test_utils.py (94%) rename {astrodbkit2 => astrodbkit}/tests/test_views.py (98%) rename {astrodbkit2 => astrodbkit}/utils.py (98%) rename {astrodbkit2 => astrodbkit}/views.py (100%) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index bf89fb6..312ea4c 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Test Astrodbkit2 +name: Test Astrodbkit on: push: @@ -33,7 +33,7 @@ jobs: # stop the build if there are Python syntax errors or undefined names ruff check astrodbkit2 --select=E9,F63,F7,F82 --statistics # exit-zero treats all errors as warnings. - ruff check astrodbkit2 --config=pyproject.toml --exit-zero + ruff check astrodbkit --config=pyproject.toml --exit-zero - name: Test with pytest run: | pytest --cov --cov-config=setup.cfg --cov-report=term --cov-report=xml:coverage.xml diff --git a/astrodbkit2/__init__.py b/astrodbkit/__init__.py similarity index 100% rename from astrodbkit2/__init__.py rename to astrodbkit/__init__.py diff --git a/astrodbkit2/astrodb.py b/astrodbkit/astrodb.py similarity index 100% rename from astrodbkit2/astrodb.py rename to astrodbkit/astrodb.py diff --git a/astrodbkit2/schema_example.py b/astrodbkit/schema_example.py similarity index 98% rename from astrodbkit2/schema_example.py rename to astrodbkit/schema_example.py index 533ad64..3cbea19 100644 --- a/astrodbkit2/schema_example.py +++ b/astrodbkit/schema_example.py @@ -8,8 +8,8 @@ from sqlalchemy import Boolean, Column, Enum, Float, ForeignKey, String from sqlalchemy.orm import validates -from astrodbkit2.astrodb import Base -from astrodbkit2.views import view +from astrodbkit.astrodb import Base +from astrodbkit.views import view # ------------------------------------------------------------------------------------------------------------------- diff --git a/astrodbkit2/spectra.py b/astrodbkit/spectra.py similarity index 100% rename from astrodbkit2/spectra.py rename to astrodbkit/spectra.py diff --git a/astrodbkit2/tests/__init__.py b/astrodbkit/tests/__init__.py similarity index 100% rename from astrodbkit2/tests/__init__.py rename to astrodbkit/tests/__init__.py diff --git a/astrodbkit2/tests/test_astrodb.py b/astrodbkit/tests/test_astrodb.py similarity index 99% rename from astrodbkit2/tests/test_astrodb.py rename to astrodbkit/tests/test_astrodb.py index 40cf76a..ff8cbda 100644 --- a/astrodbkit2/tests/test_astrodb.py +++ b/astrodbkit/tests/test_astrodb.py @@ -13,9 +13,9 @@ from astropy.units.quantity import Quantity from sqlalchemy.exc import IntegrityError -from astrodbkit2.astrodb import Database, copy_database_schema, create_database -from astrodbkit2.schema_example import * -from astrodbkit2.views import view +from astrodbkit.astrodb import Database, copy_database_schema, create_database +from astrodbkit.schema_example import * +from astrodbkit.views import view try: import mock diff --git a/astrodbkit2/tests/test_spectra.py b/astrodbkit/tests/test_spectra.py similarity index 99% rename from astrodbkit2/tests/test_spectra.py rename to astrodbkit/tests/test_spectra.py index 4e6bf04..361b2b5 100644 --- a/astrodbkit2/tests/test_spectra.py +++ b/astrodbkit/tests/test_spectra.py @@ -5,7 +5,7 @@ from astropy.io import fits from astropy.units import Unit -from astrodbkit2.spectra import ( +from astrodbkit.spectra import ( _identify_spex, identify_spex_prism, identify_wcs1d_multispec, diff --git a/astrodbkit2/tests/test_utils.py b/astrodbkit/tests/test_utils.py similarity index 94% rename from astrodbkit2/tests/test_utils.py rename to astrodbkit/tests/test_utils.py index e5240d9..155923b 100644 --- a/astrodbkit2/tests/test_utils.py +++ b/astrodbkit/tests/test_utils.py @@ -8,7 +8,7 @@ import pytest from astropy.table import Table -from astrodbkit2.utils import _name_formatter, datetime_json_parser, get_simbad_names, json_serializer +from astrodbkit.utils import _name_formatter, datetime_json_parser, get_simbad_names, json_serializer try: import mock diff --git a/astrodbkit2/tests/test_views.py b/astrodbkit/tests/test_views.py similarity index 98% rename from astrodbkit2/tests/test_views.py rename to astrodbkit/tests/test_views.py index e554a22..5f27ceb 100644 --- a/astrodbkit2/tests/test_views.py +++ b/astrodbkit/tests/test_views.py @@ -4,7 +4,7 @@ import sqlalchemy as sa from sqlalchemy.orm import Session, declarative_base -from astrodbkit2.views import * +from astrodbkit.views import * def test_views(): diff --git a/astrodbkit2/utils.py b/astrodbkit/utils.py similarity index 98% rename from astrodbkit2/utils.py rename to astrodbkit/utils.py index 974117c..0e2b440 100644 --- a/astrodbkit2/utils.py +++ b/astrodbkit/utils.py @@ -1,4 +1,4 @@ -"""Utility functions for Astrodbkit2""" +"""Utility functions for Astrodbkit""" import functools import re diff --git a/astrodbkit2/views.py b/astrodbkit/views.py similarity index 100% rename from astrodbkit2/views.py rename to astrodbkit/views.py diff --git a/docs/astrodb.rst b/docs/astrodb.rst index 09b7e70..31f49d1 100644 --- a/docs/astrodb.rst +++ b/docs/astrodb.rst @@ -1,7 +1,7 @@ astrodb module ============== -.. automodule:: astrodbkit2.astrodb +.. automodule:: astrodbkit.astrodb :members: :ignore-module-all: :undoc-members: diff --git a/docs/index.rst b/docs/index.rst index 81037a3..8c9edcd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,52 +1,50 @@ ************************* -AstrodbKit2 Documentation +AstrodbKit Documentation ************************* -**AstrodbKit2** is an astronomical database handler code built on top of SQLAlchemy. +**AstrodbKit** is an astronomical database handler code built on top of SQLAlchemy. The goal behind this code is to provide SQLAlchemy's powerful `Object Relational Mapping (ORM) `_ infrastructure to access astronomical database contents regardless of the underlying architecture. -**Astrodbkit2** is inspired from the original **astrodbkit**, which is hardcoded for the SQLite BDNYC database. - Introduction ============ Astronomical databases tend to focus on targets or observations with ancillary data that support them. -**Astrodbkit2** is designed to work with these types of databases and adopts several principles +**AstrodbKit** is designed to work with these types of databases and adopts several principles for some of its more advanced features. These are: - There exists a primary table with object identifiers - There exists any number of supplementary tables that either refer back to the primary table or exist independently For example, the `SIMPLE database `_ -(which was the initial design for **Astrodbkit2**) contains: +(which was the initial design for **AstrodbKit**) contains: - the primary Sources table, with coordinate information for each target - several object data tables, like Photometry, Spectra, etc, that contain information for each target - reference tables, like Publications, Telescopes, etc, that list other information that is used throughout the database, but doesn't refer to a particular target -The goal of **Astrodbkit2** is to link together the object tables together in order +The goal of **AstrodbKit** is to link together the object tables together in order to express them as a single entity, while still retaining the information for other reference tables. -**Astrodbkit2** can read and write out an entire target's data as a single JSON file for ease of transport and version +**AstrodbKit** can read and write out an entire target's data as a single JSON file for ease of transport and version control. Reference tables are also written as JSON files, but organized differently- a single file per table with multiple records. -An **Astrodbkit2**-supported database can thus be exported to two types of JSON files: +An **AstrodbKit**-supported database can thus be exported to two types of JSON files: individual target files and reference table files -If your database is constructed in a similar fashion, it will work well with **Astrodbkit2**. -Other databases can still benefit from some of the functionality of **Astrodbkit2**, +If your database is constructed in a similar fashion, it will work well with **AstrodbKit**. +Other databases can still benefit from some of the functionality of **AstrodbKit**, but they might not work properly if attempting to use the save/load methods. Getting Started =============== -To install **Astrodbkit2**, do:: +To install **AstrodbKit**, do:: - pip install astrodbkit2 + pip install astrodbkit or directly via the Github repo:: - pip install git+https://github.com/dr-rodriguez/AstrodbKit2 + pip install git+https://github.com/dr-rodriguez/AstrodbKit Creating a Database =================== @@ -56,7 +54,7 @@ An example schema is provided (see schema_example.py), but users can also refer to the `SIMPLE schema `_. With that on hand, users should import their schema and prepare the database:: - from astrodbkit2.astrodb import create_database + from astrodbkit.astrodb import create_database from simple.schema import * connection_string = 'sqlite:///SIMPLE.db' # connection string for a SQLite database named SIMPLE.db @@ -66,27 +64,27 @@ Accessing the Database ====================== To start using the database, launch Python, import the module, -then initialize the database with the :py:class:`astrodbkit2.astrodb.Database()` class like so:: +then initialize the database with the :py:class:`astrodbkit.astrodb.Database()` class like so:: - from astrodbkit2.astrodb import Database + from astrodbkit.astrodb import Database connection_string = 'sqlite:///SIMPLE.db' # SQLite connection string db = Database(connection_string) The database is now read to be used. If the database is empty, see below how to populate it. -.. note:: The :py:class:`astrodbkit2.astrodb.Database()` class has many parameters that can be set to +.. note:: The :py:class:`astrodbkit.astrodb.Database()` class has many parameters that can be set to control the names of primary/reference tables. By default, these match the SIMPLE database, but users can configure them for their own needs and can pass them here or modify their __init__.py file. Loading the Database -------------------- -**Astrodbkit2** contains methods to output the full contents of the database as a list of JSON files. +**AstrodbKit** contains methods to output the full contents of the database as a list of JSON files. It can likewise read in a directory of these files to populate the database. This is how SIMPLE is currently version controlled. To load a database of this form, do the following:: - from astrodbkit2.astrodb import Database + from astrodbkit.astrodb import Database connection_string = 'sqlite:///SIMPLE.db' # SQLite connection string db_dir = 'data' # directory where JSON files are located @@ -94,7 +92,7 @@ This is how SIMPLE is currently version controlled. To load a database of this f db.load_database(db_dir) .. note:: Database contents are cleared when loading from JSON files to ensure that the database only contains - sources from on-disk files. We describe later how to use the :py:meth:`~astrodbkit2.astrodb.Database.save_db` method + sources from on-disk files. We describe later how to use the :py:meth:`~astrodbkit.astrodb.Database.save_db` method to produce JSON files from the existing database contents. Loading SQLite databases with Windows @@ -104,7 +102,7 @@ Large databases may significantly slow down when attempted to load to a SQLite b To avoid this, one can create the load database purely in memory and then connect to it when it's ready. For example:: - from astrodbkit2.astrodb import Database + from astrodbkit.astrodb import Database connection_string = 'sqlite:///SIMPLE.db' # SQLite connection string db_dir = 'data' # directory where JSON files are located @@ -121,13 +119,13 @@ For example:: Querying the Database ===================== -Upon connecting to a database, **Astrodbkit2** creates methods for each table defined in the schema. +Upon connecting to a database, **AstrodbKit** creates methods for each table defined in the schema. This allows for a more pythonic approach to writing queries. There are also methods to perform specialized queries. Exploring the Schema -------------------- -The database schema is accessible via the :py:attr:`~astrodbkit2.astrodb.Database.metadata` attribute. +The database schema is accessible via the :py:attr:`~astrodbkit.astrodb.Database.metadata` attribute. For example, to see the available tables users can do:: @@ -153,7 +151,7 @@ Specialized Searches Identifier (name) Search ~~~~~~~~~~~~~~~~~~~~~~~~ -To search for an object by name, users can use the :py:meth:`~astrodbkit2.astrodb.Database.search_object` +To search for an object by name, users can use the :py:meth:`~astrodbkit.astrodb.Database.search_object` method to do fuzzy searches on the provided name, output results from any table, and also include alternate Simbad names for their source. Refer to the API documentation for full details. @@ -172,7 +170,7 @@ Search for any source with 1357+1428 in its name and return results from the Pho Inventory Search ~~~~~~~~~~~~~~~~ -**Astrodbkit2** also contains an :py:meth:`~astrodbkit2.astrodb.Database.inventory` method to return all data for a source by its name:: +**AstrodbKit** also contains an :py:meth:`~astrodbkit.astrodb.Database.inventory` method to return all data for a source by its name:: data = db.inventory('2MASS J13571237+1428398') print(data) # output as a dictionary, with individual tables as results @@ -220,13 +218,13 @@ The pretty_print parameter can be passed to print out results to the screen in a Region (spatial) Search ~~~~~~~~~~~~~~~~~~~~~~~ -Another query method available in **Astrodbkit2** is :py:meth:`~astrodbkit2.astrodb.Database.query_region`. +Another query method available in **AstrodbKit** is :py:meth:`~astrodbkit.astrodb.Database.query_region`. This performs a cone search around a given location for sources in the database. It expects astropy SkyCoord and Quantity objects for the position and radius:: db.query_region(SkyCoord(209.301675, 14.477722, frame='icrs', unit='deg'), radius=Quantity(60., unit='arcsec')) -Similar to :py:meth:`~astrodbkit2.astrodb.Database.search_object`, a variety of options can be passed to control the output. +Similar to :py:meth:`~astrodbkit.astrodb.Database.search_object`, a variety of options can be passed to control the output. If the table with coordinate information is not the primary table, it can be specifed as well:: db.query_region(SkyCoord(209., 14., frame='icrs', unit='deg'), output_table='Photometry') # returning Photometry results for this search @@ -237,7 +235,7 @@ Full String Search ~~~~~~~~~~~~~~~~~~~~~~~ Similar to the Identifier Search above, one can perform a case-insensitive search for -any string against every string column in the database with :py:meth:`~astrodbkit2.astrodb.Database.search_string`. +any string against every string column in the database with :py:meth:`~astrodbkit.astrodb.Database.search_string`. The output is a dictionary with keys for each table that matched results. This can be useful to find all results matching a particular reference regardless of table:: @@ -249,7 +247,7 @@ General Queries -------------------- Frequently, users may wish to perform specialized queries against the full database. -This can be used with the SQLAlchemy ORM and a convenience method, :py:attr:`~astrodbkit2.astrodb.Database.query`, exists for this. +This can be used with the SQLAlchemy ORM and a convenience method, :py:attr:`~astrodbkit.astrodb.Database.query`, exists for this. For more details on how to use SQLAlchemy, refer to `their documentation `_. Here are a few examples. @@ -286,7 +284,7 @@ Example queries showing how to perform ANDs and ORs:: # Query with OR db.query(db.Sources).filter(or_(db.Sources.c.dec < 0, db.Sources.c.ra > 200)).all() -In addition to using the ORM, it is useful to note that a :py:meth:`~astrodbkit2.astrodb.Database.sql_query` method exists +In addition to using the ORM, it is useful to note that a :py:meth:`~astrodbkit.astrodb.Database.sql_query` method exists to pass direct SQL queries to the database for users who may wish to write their own SQL statements:: results = db.sql_query('select * from sources', fmt='astropy') @@ -295,7 +293,7 @@ to pass direct SQL queries to the database for users who may wish to write their General Queries with Transformations ------------------------------------ -**Astrodbkit2** can convert columns to special types. +**AstrodbKit** can convert columns to special types. Currently, spectra transformations are implemented and the specified column would be converted to a `Spectrum1D` object using the `specutils package `_. To call this, users can supply the name of the column to convert @@ -311,7 +309,7 @@ The parameter `spectra_format` can be specified if **specutils** is having troub Spectra need to be specified as either URL or paths relative to an environment variable, for example `$ASTRODB_SPECTRA/infrared/myfile.fits`. -**AstrodbKit2** would examine the environment variable `$ASTRODB_SPECTRA` and use that as +**AstrodbKit** would examine the environment variable `$ASTRODB_SPECTRA` and use that as part of the absolute path to the file. Working With Views @@ -347,7 +345,7 @@ When created, the database will contain these views and users can reflect them t It is important that `sa.MetaData()` be used in the `sa.Table()` call as you don't want to modify the metadata of the actual database. -If you don't do this and instead use `db.metadata`, you may end up with errors in other parts of AstrodbKit2 +If you don't do this and instead use `db.metadata`, you may end up with errors in other parts of AstrodbKit functionality as the view will be treated as a physical table. Modifying Data @@ -372,7 +370,7 @@ The simplest way to add data to an existing database is to construct a list of d conn.execute(db.Sources.insert().values(sources_data)) conn.commit() # sqlalchemy 2.0 does not autocommit -As a convenience method, users can use the :py:meth:`~astrodbkit2.astrodb.Database.add_table_data` method +As a convenience method, users can use the :py:meth:`~astrodbkit.astrodb.Database.add_table_data` method to load user-supplied tables into database tables. If not loading the primary table, the code will first check for missing sources and print those out for the user to correct them. Column names should match those in the database, but extra columns in the supplied table are ignored. @@ -406,7 +404,7 @@ Saving the Database =================== If users perform changes to a database, they will want to output this to disk to be version controlled. -**Astrodbkit2** provides methods to save an individual source or reference table as well as the entire data. +**AstrodbKit** provides methods to save an individual source or reference table as well as the entire data. We recommend the later to output the entire contents to disk:: # Save single object @@ -455,7 +453,7 @@ For example, the schema of your sources table could be written to validate RA/De In your scripts, you can then create objects and populate them accordingly. For example:: - from astrodbkit2.astrodb import Database + from astrodbkit.astrodb import Database from schema import Sources db = Database(connection_string) diff --git a/docs/spectra.rst b/docs/spectra.rst index ffc3fd4..eab6ac8 100644 --- a/docs/spectra.rst +++ b/docs/spectra.rst @@ -1,7 +1,7 @@ spectra module ============== -.. automodule:: astrodbkit2.spectra +.. automodule:: astrodbkit.spectra :members: :ignore-module-all: :undoc-members: diff --git a/docs/utils.rst b/docs/utils.rst index 6958301..e5f3422 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -1,7 +1,7 @@ utils module ============== -.. automodule:: astrodbkit2.utils +.. automodule:: astrodbkit.utils :members: :ignore-module-all: :undoc-members: diff --git a/pyproject.toml b/pyproject.toml index 4276f07..e4c1d18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = 'setuptools.build_meta' [project] -name = "astrodbkit2" +name = "astrodbkit" description = "Astronomical database handler code" dynamic = ["version"] readme = {file = "README.rst", content-type = "text/x-rst"} @@ -42,43 +42,43 @@ test = [ docs = [ "sphinx-astropy" ] -all = ["astrodbkit2[test, docs]"] +all = ["astrodbkit[test, docs]"] [project.urls] -Repository = "https://github.com/astrodbtoolkit/AstrodbKit2" +Repository = "https://github.com/astrodbtoolkit/AstrodbKit" [tool.setuptools] -packages = ["astrodbkit2"] +packages = ["astrodbkit"] [tool.setuptools.dynamic] -version = {attr = "astrodbkit2.__version__"} +version = {attr = "astrodbkit.__version__"} [tool.setuptools_scm] # can be empty if no extra settings are needed, presence enables setuptools_scm -version_file = "astrodbkit2/version.py" +version_file = "astrodbkit/version.py" [tool.pytest.ini_options] -testpaths = "astrodbkit2" +testpaths = "astrodbkit" [tool.coverage.run] omit = [ - "astrodbkit2/_astropy_init*", - "astrodbkit2/conftest.py", - "astrodbkit2/*setup_package*", - "astrodbkit2/tests/*", - "astrodbkit2/*/tests/*", - "astrodbkit2/extern/*", - "astrodbkit2/version*", - "*/astrodbkit2/_astropy_init*", - "*/astrodbkit2/conftest.py", - "*/astrodbkit2/*setup_package*", - "*/astrodbkit2/tests/*", - "*/astrodbkit2/*/tests/*", - "*/astrodbkit2/extern/*", - "*/astrodbkit2/version*", + "astrodbkit/_astropy_init*", + "astrodbkit/conftest.py", + "astrodbkit/*setup_package*", + "astrodbkit/tests/*", + "astrodbkit/*/tests/*", + "astrodbkit/extern/*", + "astrodbkit/version*", + "*/astrodbkit/_astropy_init*", + "*/astrodbkit/conftest.py", + "*/astrodbkit/*setup_package*", + "*/astrodbkit/tests/*", + "*/astrodbkit/*/tests/*", + "*/astrodbkit/extern/*", + "*/astrodbkit/version*", ] diff --git a/setup.cfg b/setup.cfg index f8dd489..2e2fe57 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] -name = astrodbkit2 +name = astrodbkit author = David Rodriguez edit_on_github = False -github_project = dr-rodriguez/AstrodbKit2 +github_project = astrodbtoolkit/AstrodbKit # Most details are now in pyproject.toml From 658a0c1a0c0e039bba97dd4695835ad4a25c1e70 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 11 Sep 2024 11:40:33 -0400 Subject: [PATCH 2/5] Updating readme --- README.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 75a24e9..9addc53 100644 --- a/README.rst +++ b/README.rst @@ -5,17 +5,17 @@ Astronomical database handler code :target: http://www.astropy.org :alt: Powered by Astropy Badge -.. image:: https://github.com/astrodbtoolkit/AstrodbKit2/workflows/Test%20Astrodbkit2/badge.svg?branch=main - :target: https://github.com/astrodbtoolkit/AstrodbKit2/actions +.. image:: https://github.com/astrodbtoolkit/AstrodbKit/workflows/Test%20Astrodbkit/badge.svg?branch=main + :target: https://github.com/astrodbtoolkit/AstrodbKit/actions -.. image:: https://codecov.io/gh/astrodbtoolkit/AstrodbKit2/graph/badge.svg?token=LMKVN65D82 - :target: https://codecov.io/gh/astrodbtoolkit/AstrodbKit2 +.. image:: https://codecov.io/gh/astrodbtoolkit/AstrodbKit/graph/badge.svg?token=LMKVN65D82 + :target: https://codecov.io/gh/astrodbtoolkit/AstrodbKit -AstrodbKit2 is an astronomical database handler code built on top of SQLAlchemy. +AstrodbKit is an astronomical database handler code built on top of SQLAlchemy. This is built to work with the `SIMPLE database `_, though similarly constructed databases will work. -Documentation is available at `https://astrodbkit2.readthedocs.io/en/latest/ `_ +Documentation is available at `https://astrodbkit.readthedocs.io/en/latest/ `_ License ------- @@ -30,7 +30,7 @@ more information. Contributing ------------ -We love contributions! `AstrodbKit2 `_ is open source, +We love contributions! `AstrodbKit `_ is open source, built on open source, and we'd love to have you hang out in our community. **Imposter syndrome disclaimer**: We want your help. No, really. @@ -56,5 +56,5 @@ the errors and assumptions that seasoned contributors have glossed over. Note: This disclaimer was originally written by `Adrienne Lowe `_ for a `PyCon talk `_, and was adapted by -AstrodbKit2 based on its use in the README file for the +AstrodbKit based on its use in the README file for the `MetPy project `_. From 8f0aa393fef82bbf291c1658651effa27f6e1e4f Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 11 Sep 2024 11:50:21 -0400 Subject: [PATCH 3/5] Updating tests --- astrodbkit/tests/test_astrodb.py | 4 ++-- astrodbkit/tests/test_spectra.py | 12 ++++++------ astrodbkit/tests/test_utils.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/astrodbkit/tests/test_astrodb.py b/astrodbkit/tests/test_astrodb.py index ff8cbda..b93caaa 100644 --- a/astrodbkit/tests/test_astrodb.py +++ b/astrodbkit/tests/test_astrodb.py @@ -196,7 +196,7 @@ def test_query_data(db): assert db.query(db.Sources.c.source).limit(1).all()[0][0] == '2MASS J13571237+1428398' -@mock.patch('astrodbkit2.astrodb.get_simbad_names', return_value=['fake']) +@mock.patch('astrodbkit.astrodb.get_simbad_names', return_value=['fake']) def test_search_object(mock_simbad, db): # Use the search_object method to do partial string searching @@ -309,7 +309,7 @@ def test_query_formats(db): assert isinstance(t, pd.DataFrame) -@mock.patch('astrodbkit2.astrodb.load_spectrum') +@mock.patch('astrodbkit.astrodb.load_spectrum') def test_query_spectra(mock_spectrum, db): # Test special conversions in query methods def fake_loader(x, spectra_format=None): diff --git a/astrodbkit/tests/test_spectra.py b/astrodbkit/tests/test_spectra.py index 361b2b5..738f452 100644 --- a/astrodbkit/tests/test_spectra.py +++ b/astrodbkit/tests/test_spectra.py @@ -85,7 +85,7 @@ def alt_wcs1dmultispec(): return fits.HDUList([hdu1]) -@mock.patch("astrodbkit2.spectra.fits.open") +@mock.patch("astrodbkit.spectra.fits.open") def test_identify_spex_prism(mock_fits_open, good_spex_file): mock_fits_open.return_value = good_spex_file @@ -95,7 +95,7 @@ def test_identify_spex_prism(mock_fits_open, good_spex_file): assert not identify_spex_prism("read", filename) -@mock.patch("astrodbkit2.spectra.fits.open") +@mock.patch("astrodbkit.spectra.fits.open") def test_identify_spex(mock_fits_open, good_spex_file, bad_spex_file): mock_fits_open.return_value = good_spex_file assert _identify_spex("filename") @@ -103,7 +103,7 @@ def test_identify_spex(mock_fits_open, good_spex_file, bad_spex_file): assert not _identify_spex("filename") -@mock.patch("astrodbkit2.spectra.fits.open") +@mock.patch("astrodbkit.spectra.fits.open") def test_load_spex_prism(mock_fits_open, good_spex_file, bad_spex_file): # Test good example mock_fits_open.return_value = good_spex_file @@ -115,7 +115,7 @@ def test_load_spex_prism(mock_fits_open, good_spex_file, bad_spex_file): assert spectrum.unit == Unit("erg") -@mock.patch("astrodbkit2.spectra.read_fileobj_or_hdulist") +@mock.patch("astrodbkit.spectra.read_fileobj_or_hdulist") def test_identify_wcs1d_multispec(mock_fits_open, good_wcs1dmultispec): mock_fits_open.return_value = good_wcs1dmultispec @@ -123,7 +123,7 @@ def test_identify_wcs1d_multispec(mock_fits_open, good_wcs1dmultispec): assert identify_wcs1d_multispec("read", filename) -@mock.patch("astrodbkit2.spectra.read_fileobj_or_hdulist") +@mock.patch("astrodbkit.spectra.read_fileobj_or_hdulist") def test_wcs1d_multispec_loader(mock_fits_open, good_wcs1dmultispec, alt_wcs1dmultispec): mock_fits_open.return_value = good_wcs1dmultispec @@ -142,7 +142,7 @@ def test_wcs1d_multispec_loader(mock_fits_open, good_wcs1dmultispec, alt_wcs1dmu assert spectrum.wavelength.unit == Unit("Angstrom") -@mock.patch("astrodbkit2.spectra.Spectrum1D.read") +@mock.patch("astrodbkit.spectra.Spectrum1D.read") def test_load_spectrum(mock_spectrum1d, monkeypatch): _ = load_spectrum("fake_file.txt") mock_spectrum1d.assert_called_with("fake_file.txt") diff --git a/astrodbkit/tests/test_utils.py b/astrodbkit/tests/test_utils.py index 155923b..c502fef 100644 --- a/astrodbkit/tests/test_utils.py +++ b/astrodbkit/tests/test_utils.py @@ -51,7 +51,7 @@ def test_datetime_json_parser(): assert isinstance(new_dict['number'], float) -@mock.patch('astrodbkit2.utils.Simbad.query_objectids') +@mock.patch('astrodbkit.utils.Simbad.query_objectids') def test_get_simbad_names(mock_simbad): mock_simbad.return_value = Table({'ID': ['name 1', 'name 2', 'V* name 3', 'HIDDEN name']}) t = get_simbad_names('twa 27') From eec3078ffd72981af907d502eb2b1e2f4f308466 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 11 Sep 2024 11:55:14 -0400 Subject: [PATCH 4/5] updating manifest --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 3fa3e1c..cec1c3d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,7 @@ include setup.cfg include LICENSE.rst include pyproject.toml -recursive-include astrodbkit2 *.pyx *.c *.pxd +recursive-include astrodbkit *.pyx *.c *.pxd recursive-include docs * recursive-include licenses * recursive-include scripts * From d9465ec499f30a39442178e8e15e234b308b21d8 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 11 Sep 2024 12:49:11 -0400 Subject: [PATCH 5/5] Updating github actions --- .github/workflows/python-publish.yml | 4 ++-- .github/workflows/test-package.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 079338c..4269019 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.8 - name: Install dependencies diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 312ea4c..cc5c846 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -18,9 +18,9 @@ jobs: python-version: [3.8, 3.9, '3.10', 3.11] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -31,7 +31,7 @@ jobs: - name: Lint with ruff run: | # stop the build if there are Python syntax errors or undefined names - ruff check astrodbkit2 --select=E9,F63,F7,F82 --statistics + ruff check astrodbkit --select=E9,F63,F7,F82 --statistics # exit-zero treats all errors as warnings. ruff check astrodbkit --config=pyproject.toml --exit-zero - name: Test with pytest