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

phoebe-server style updates #960

Open
wants to merge 1 commit into
base: release-2.5
Choose a base branch
from

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Oct 14, 2024

This PR improves style-adherence in phoebe-server

@matthiasfabry
Copy link
Collaborator

I ❤️ style improvements!
What PEP(s) are we following?

@kecnry
Copy link
Member Author

kecnry commented Oct 14, 2024

I'd like to enforce pep-8 - maybe with extended line length and a few other exceptions - on new PRs (I'll add that to my list to add a check in the CI) and then eventually-eventually work to update the existing codebase (that's just hard to do in one chunk because of all the feature branches and potential conflicts).

@kecnry kecnry force-pushed the server-style-updates branch from 00dab57 to bf2bf3a Compare October 28, 2024 18:27
@kecnry kecnry self-assigned this Oct 28, 2024
@kecnry kecnry marked this pull request as ready for review October 28, 2024 18:29
@kecnry kecnry requested a review from aprsa January 9, 2025 14:38
@@ -584,8 +578,8 @@ def new_bundle(type):
type: 'binary:detached'
"""
j = _get_request(request)
clientid = j.get('clientid', None) if j is not None else None
client_version = j.get('client_version', None) if j is not None else None
#clientid = j.get('clientid', None) if j is not None else None
Copy link
Contributor

Choose a reason for hiding this comment

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

if adhering to style, then we should add a space after the comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not trying to completely adhere to style (yet), but can make this update

@@ -595,7 +589,8 @@ def new_bundle(type):
b = getattr(phoebe, constructor)(**kwargs)
except Exception as err:
return _get_response({'success': False, 'error': str(err)}, api=True)
if app._debug: raise
if app._debug:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

can we be more targeted with this raise?

Copy link
Member Author

Choose a reason for hiding this comment

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

how so?

Copy link
Contributor

Choose a reason for hiding this comment

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

by raising a specific exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, this just raises the same exception that triggered the except

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, I'm well aware; I just thought further context might be warranted. But maybe not.

return _get_response({'success': False, 'error': "could not read json data ({})".format(err)}, api=True)
if app._debug: raise
if app._debug:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

return _get_response({'success': False, 'error': "failed to load bundle with error: "+str(err)}, api=True)
if app._debug: raise
if app._debug:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above


elif type == 'load:legacy':
try:
b = phoebe.from_legacy(request.files['file'])
except Exception as err:
return _get_response({'success': False, 'error': "file not recognized as bundle or legacy phoebe file. Error: {}".format(str(err))}, api=True)
if app._debug: raise
if app._debug:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@@ -760,24 +759,24 @@ def export_script(bundleid):
f.write(log.get_export_script())
except Exception as err:
f.close()
if app._debug: raise
if app._debug:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@app.route('/export_compute/<string:bundleid>/<string:compute>', defaults={'model': None}, methods=['GET', 'POST'])
@app.route('/export_compute/<string:bundleid>/<string:compute>/<string:model>', methods=['GET', 'POST'])
@crossdomain(origin='*')
def export_compute(bundleid, compute, model=None):
"""
"""
j = _get_request(request)
clientid = j.get('clientid', None) if j is not None else None
client_version = j.get('client_version', None) if j is not None else None
#clientid = j.get('clientid', None) if j is not None else None
Copy link
Contributor

Choose a reason for hiding this comment

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

add space after #

@@ -806,8 +805,8 @@ def export_solver(bundleid, solver, solution=None):
"""
"""
j = _get_request(request)
clientid = j.get('clientid', None) if j is not None else None
client_version = j.get('client_version', None) if j is not None else None
#clientid = j.get('clientid', None) if j is not None else None
Copy link
Contributor

Choose a reason for hiding this comment

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

add space after #

@@ -835,8 +834,8 @@ def export_params(bundleid, params):
"""
"""
j = _get_request(request)
clientid = j.get('clientid', None) if j is not None else None
client_version = j.get('client_version', None) if j is not None else None
#clientid = j.get('clientid', None) if j is not None else None
Copy link
Contributor

Choose a reason for hiding this comment

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

space missing

@app.route('/bundle/<string:bundleid>', methods=['GET', 'POST'])
@crossdomain(origin='*')
def bundle(bundleid):
"""
"""
j = _get_request(request)
clientid = j.get('clientid', None) if j is not None else None
client_version = j.get('client_version', None) if j is not None else None
#clientid = j.get('clientid', None) if j is not None else None
Copy link
Contributor

Choose a reason for hiding this comment

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

space missing; I will no longer flag duplicates below for this or for a naked raise

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.

3 participants