-
Notifications
You must be signed in to change notification settings - Fork 13
Canfar Python Libraries #702
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
base: develop
Are you sure you want to change the base?
Conversation
cailmdaley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work modernising the CANFAR submission path and replacing CDSClient with astroquery. The documentation rewrite is a real improvement. A few things to fix before merge — mostly runtime bugs that will crash in production, plus some smaller items.
Bugs that will crash
canfar_monitor.py:130—RunTimeError→RuntimeErrorcanfar_monitor.py:188—self._get_kind()→self.get_kind()(no underscore)canfar_monitor.py:121—self._params["verbose"]referenced but never defined inparams_defaultcanfar_monitor.py:206-208—elseaftertry/exceptruns on success, not failure. The "Failed to destroy" message fires when destruction succeeds.canfar_monitor.py:222,235—"failed{estr}"missingfprefixsummary.py:218,235—mgsinstead ofmsg—NameErrorat runtimeclear_ngmix_prev.py:117— globsngmix_out_dirwhen it should globprev_out_dirdistribute_tiles.py:124— compares string args with int literals(0, 1)— will never match, should be('0', '1')
Intentional?
make_cat.py:348— threshold changed from0.9to0.0. Since a ratio can't be negative, this disables the check entirely. If intentional, the dead code block could be removed or at least commented with why.
Style / design
distribute_tiles.py:1— hardcoded shebang#!/arc/home/kilbinger/...uncompress_fits.py:62— bareexcept:— worth catching something specificuncompress_fits.py:75-76— theTFORMfix runs outside theif name:guard, so on empty keysvalue/commentare stale from the previous iterationcanfar_submit.py:32-33— the!= 512guard can never trigger (set to 512 on the line above)canfar_submit.py:260—AsyncSession()opened twice (once inrun_async, again in_submit_single_batch)pyproject.toml—requires-pythondowngraded from>=3.11to>=3.10without mention. Alsocanfar,sf_tools,h5py,pandasadded as core deps — could these live under an optional[canfar]extra?- Star imports in
summary_run.pyandsummary_params_pre_v2.py
Typos
canfar_monitor.py:3— "Montiot" → "Monitor"canfar_monitor.py:247— "Retreiving" → "Retrieving"mask.py:498— "astroquer" → "astroquery"canfar_submit.py:116— "SESSSION" (triple S)mask.py:496-501—IndexErrorraised with positional args instead of a formatted string
Tests
None of the new code has tests. The mgs/msg typo in summary.py would have been caught immediately.
|
Check again please @cailmdaley, I answered to all points of your PR report. Thanks! |
- canfar_monitor: "Montior" typo, try/except/else flow for bulk destroy - canfar_submit: "debut_out" dict key typo - uncompress_fits: header assignment inside if-name guard - distribute_tiles: check arg value not flag name for dry_run Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey Martin, thanks for the fixes! I took the liberty of pushing a few more small ones I spotted while verifying:
Let me know if I made any mistakes. Have a nice weekend! |
sfarrens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @martinkilbinger sorry for the delay. I am a bit rusty on ShapePipe 😅, so I may have missed something, but overall the proposed changes look fine. I opened a few threads to resolve some minor issues.
| - defaults | ||
| dependencies: | ||
| - python=3.9 | ||
| - python=3.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a different Python version in the pyproject.toml and environment.yml?
| from shapepipe.utilities.summary import * | ||
|
|
||
| from summary_params_pre_v2 import * | ||
| from shapepipe.utilities.summary_params_pre_v2 import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really important for this PR, but in general it is not good practice to use import * as it makes it harder to trace the origin of objects. It would be better to from shapepipe.utilities import summary_params_pre_v2 if you need the whole module or to simple import the objects you actually need.
| if len(args) == 3: | ||
| verbose = True | ||
| else: | ||
| verbose = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another unimportant point, this could all be done in one line:
verbose = len(args) == 3| Main program | ||
| """ | ||
| # Scripts to call canfar classes are created by pyproject.toml | ||
| return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but strictly speaking there should be some docstrings to explain the point of the module and the corresponding functions.
| self._patch = os.environ["patch"] if "patch" in os.environ else "P0" | ||
|
|
||
| # Set job parameters | ||
| version = "1.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this hardcoded here?
| print(f"Each session will process ~{math.ceil(total_n / num_replicas)} jobs using chunk()") | ||
| print("Sessions = ", sessions) | ||
| except Exception as e: | ||
| print(f"❌ CANFAR session.create() failed: {type(e).__name__}: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be surprised if printing emojis worked universally, but fine if it works where you need to run it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't spot any major issues, but more docstrings would be good.
| def check_params(self): | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point re: docstrings
Summary
This PR updates job hanling on canfar to the new canfar python library system.
This comes with job submission and monitoring classes and scripts.
New tiles (P9) were added to the CFIS tile list.
Closes some old issues #669 .
Reviewer Checklist
developbranch