diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9345c2e..420212b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,7 @@ "forwardPorts": [8000], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip install -r requirements.txt && wget -O SIMPLE.db https://raw.githubusercontent.com/SIMPLE-AstroDB/SIMPLE-binary/main/SIMPLE.db && python simple_app/app_simple.py -d" + "postCreateCommand": "pip install -r requirements.txt && wget -O SIMPLE.db https://raw.githubusercontent.com/SIMPLE-AstroDB/SIMPLE-binary/main/SIMPLE.db && python -m simple_app.app_simple -d" // Configure tool-specific properties. // "customizations": {}, diff --git a/simple_app/templates/about.html b/simple_app/templates/about.html index 7a7dd29..cb1709e 100644 --- a/simple_app/templates/about.html +++ b/simple_app/templates/about.html @@ -18,7 +18,7 @@

The SIMPLE Archive

We are currently working on including kinematics, spectra, images, and modelled and retrieved parameters. We are developing several different methods to interact with the database, including python, - a website and API, and database browsers. + a website and API, and database browsers.
This database uses the SQLAlchemy ORM and is designed to be interacted with via the astrodbkit2 package. @@ -37,16 +37,16 @@

Getting Involved

Imposter syndrome disclaimer:

- We want your help. No, really. + We want your help. No, really.
There may be a little voice inside your head that is telling you that you’re not ready to be an open-source contributor; that your skills aren’t nearly good enough to contribute. What could you possibly offer a project like this one? - We assure you - the little voice in your head is wrong. + We assure you - the little voice in your head is wrong.
If you can write code at all, you can contribute code to open source. Contributing to open-source projects is a fantastic way to advance one’s coding skills. Writing perfect code isn’t the measure of a good developer (that would disqualify all of us!); it’s trying to create something, making mistakes, and learning from those mistakes. - That’s how we all improve, and we are happy to help others learn. + That’s how we all improve, and we are happy to help others learn.
Being an open-source contributor doesn’t just mean writing code, either. You can help by writing documentation, tests, or even giving feedback about the project (and yes - that includes giving feedback about the contribution process). diff --git a/simple_app/templates/index_simple.html b/simple_app/templates/index_simple.html index ddf91f8..09710ce 100644 --- a/simple_app/templates/index_simple.html +++ b/simple_app/templates/index_simple.html @@ -42,31 +42,29 @@

Welcome!

Figures

-
+
+ class="rounded img-fluid float-xxl-start" alt="">
-
+
+ class="rounded img-fluid mx-auto d-block" alt="">
-
-
-
+
-
-
-
-
+
+ +
+
+ class="rounded img-fluid mx-auto d-block" alt="">
-
+
diff --git a/simple_app/tests/test_utils.py b/simple_app/tests/test_utils.py index 7c87815..0bd20fb 100644 --- a/simple_app/tests/test_utils.py +++ b/simple_app/tests/test_utils.py @@ -127,7 +127,7 @@ def test_results_concat(db, test_get_all_photometry, test_get_all_sources, def test_one_df_query(db): assert db - bad_query = 'thisisabad_query' + bad_query = 'thisisabadquery' good_query = 'twa' # test search object results = db.search_object(bad_query, fmt='pandas') @@ -164,7 +164,7 @@ def test_one_df_query(db): def test_multi_df_query(db): assert db - bad_query = 'thisisabad_query' + bad_query = 'thisisabadquery' good_query = 'cruz' with pytest.raises(KeyError): results: Optional[dict] = db.search_string(bad_query, fmt='pandas', verbose=False) @@ -178,3 +178,35 @@ def test_multi_df_query(db): assert 'Sources' in results_out assert isinstance(results_out['Sources'], str) return + + +def test_multi_param_str_parse(): + twa_query = '174.96308 -31.989305' + empty_query = '' + hms_query = '12h34m56s \t +78d90m12s' + for query in (twa_query, empty_query, hms_query): + a, b, c = CoordQueryForm.multi_param_str_parse(query) + assert isinstance(a, str) + assert isinstance(b, str) + assert isinstance(c, float) + assert c == 10. + twa_query = '174.96308 \t -31.989305 15 ' + a, b, c = CoordQueryForm.multi_param_str_parse(twa_query) + assert a == '174.96308' + assert b == '-31.989305' + assert c == 15. + return + + +def test_ra_dec_unit_parse(): + twa_query = '174.96308 -31.989305' + a, b, c = CoordQueryForm.multi_param_str_parse(twa_query) + ra, dec, unit = CoordQueryForm.ra_dec_unit_parse(a, b) + assert isinstance(ra, float) + assert isinstance(dec, float) + assert unit == 'deg' + hms_query = '12h34m56s \t +78d90m12s' + a, b, c = CoordQueryForm.multi_param_str_parse(hms_query) + ra, dec, unit = CoordQueryForm.ra_dec_unit_parse(a, b) + assert unit == 'hourangle,deg' + return diff --git a/simple_app/utils.py b/simple_app/utils.py index e930c9c..28deb5b 100644 --- a/simple_app/utils.py +++ b/simple_app/utils.py @@ -196,8 +196,7 @@ def multi_param_str_parse(s: str) -> Optional[Tuple[str, str, float]]: """ # split up the string by empty space try: - query_split: np.ndarray = np.array(s.replace('\t', ' ').lower().strip().split(' ')) - query_split = query_split[np.logical_not(query_split == '')] + query_split = s.lower().split() query_length = len(query_split) # check length is 2 or 3 @@ -323,7 +322,7 @@ def validate_sqlfield(self, field): field The data within the query form """ - forbidden = ('update', 'drop', 'truncate', 'grant', 'commit', 'create', 'replace', 'alter', 'insert') + forbidden = ('update', 'drop', 'truncate', 'grant', 'commit', 'create', 'replace', 'alter', 'insert', 'delete') db = SimpleDB(self.db_file, connection_arguments={'check_same_thread': False}) # open database # check query field has data within