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

DM-45816 Yet even more unit tests +947-9 #35

Merged
merged 10 commits into from
Sep 10, 2024
Merged

DM-45816 Yet even more unit tests +947-9 #35

merged 10 commits into from
Sep 10, 2024

Conversation

bbrondel
Copy link
Collaborator

This PR contains the following:

  • More tests in tests/test_pqserver.py
  • Additional test data in tests/lsstcomcamsim in the form of SQL files and astropy ECSV tables
  • Fixes in pqserver.py that address problems that were identified
    And as an added bonus, functionality in hinfo to load data into the database from local disk storage.

@bbrondel bbrondel requested a review from ktlim August 28, 2024 23:21
@bbrondel bbrondel marked this pull request as ready for review August 29, 2024 16:59
@bbrondel bbrondel requested a review from Vebop August 30, 2024 16:54
Copy link
Collaborator

@Vebop Vebop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks decent overall, this does add more tests. Good Job

python/lsst/consdb/hinfo.py Outdated Show resolved Hide resolved
engine = setup_postgres()
asyncio.run(main())
if len(sys.argv) > 1:
process_local_path(sys.argv[1])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if this is called with an argument, then the service does not run as a server but just the once, is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to process a list of files/directories, rather than just one?

detector INTEGER NOT NULL,
s_region VARCHAR(1024),
PRIMARY KEY (ccdexposure_id),
CONSTRAINT un_exposure_id_detector UNIQUE (exposure_id, detector),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the CONSTRAINT names need to have the table name in them, in this case ccdexposure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't blame me, blame felis. I always hate to edit machine generated code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can fix felis and in theory build this dynamically from the felis model.

# and with fake made up flex data
with sqlite3.connect(schema_path) as conn:
conn.executescript(sql_path.read_text())
import time
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you move this import to the top of the module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't be there at all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you use time.sleep() two lines below this. Don't forget to remove that too, if that is your intention.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not required) We could move the fixtures out into their own file at this point of complexity. I have used conftest.py in the past, but if these fixtures are only used in this single file it would not make sense to put them there or modularize so much, without the test file also being broken out.

@@ -2,7 +2,7 @@ ARG OBS_LSST_VERSION=w_2024_21
FROM lsstsqre/centos:7-stack-lsst_distrib-${OBS_LSST_VERSION}
USER lsst
RUN source loadLSST.bash && mamba install aiokafka httpx
RUN source loadLSST.bash && pip install kafkit aiokafka httpx pytest-asyncio
RUN source loadLSST.bash && pip install kafkit aiokafka httpx pytest-asyncio testing.postgresql
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner if we could separate the testing and running environments. It's not a huge deal at present, but it could become so later, and it would be a good pattern to set.

You shouldn't need to mamba install and pip install the same packages. While generally mamba/conda install is slightly safer than pip install for Conda environments, the testing.postgresql package is not available in conda-forge (though pytest-postgresql, which may be similar, is), so using pip for everything makes some sense.

engine = setup_postgres()
asyncio.run(main())
if len(sys.argv) > 1:
process_local_path(sys.argv[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to process a list of files/directories, rather than just one?

json={"obs_dict": data},
)
_assert_http_status(response, 200)
assert response.json()["obs_id"] == list(data.keys())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ordering guaranteed? Maybe sort to make sure?
Might be nice to do a query to make sure that the data actually got updated.

]
tables = [f"cdb_lsstcomcamsim.{t}" for t in tables]
for t in tables:
assert t in result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows extra tables to be in the schema. Is that wise? Otherwise set equality might be better?

@JeremyMcCormick JeremyMcCormick self-requested a review September 9, 2024 21:26
Copy link
Contributor

@JeremyMcCormick JeremyMcCormick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks are failing...

  • Fix the isort issue.
  • Add lsst-felis to the pip install in Dockerfile.pytest so felis.db.utils will be found when running tests.

Copy link
Contributor

@JeremyMcCormick JeremyMcCormick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now - checks are all passing.

@bbrondel bbrondel merged commit ca09682 into main Sep 10, 2024
6 checks passed
@bbrondel bbrondel deleted the tickets/DM-45816 branch September 10, 2024 00:04
@bbrondel bbrondel restored the tickets/DM-45816 branch September 10, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants