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

Callback implementation for Python GCL API #31

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kirillsc
Copy link
Collaborator

Description

This is a draft for the Python Grid Connector Library with support of (client-based) callbacks.
This is not a final version but a draft for the code review.
What is implemented:

  • HTCGridConnector supports multiple concurrent sessions
  • Each session is an open session with the ability to add more tasks
  • Wait on tasks completion with one session, wait on all sessions completion
  • Callback mechanism
  • Example of the new API use
    What is not implemented
  • Callbacks on failed tasks
  • Documentation
  • Fix of the API in old examples

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes
  • (Core team) Added labels for change area (e.g. area/controlplane) and kind (e.g. kind/improvement)

BONUS POINTS checklist:

  • Backfilled missing tests for code in same general area
  • Refactored something and made the world a better place



def create_session(self, service_name, context, callback):

Copy link
Collaborator

Choose a reason for hiding this comment

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

docstring will be useful here


return new_session

def close(self, wait_for_sessions_completion=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Either I would rename close to delete_session or rename create_session to open

return new_session

def close(self, wait_for_sessions_completion=True):
print("Connector: Closing HTC-Grid Connector")
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use logging library instead of


return new_session

def close(self, wait_for_sessions_completion=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

docstring will be useful here

self.wait_for_sessions_completion = wait_for_sessions_completion

def register_session(self, new_session):
assert(new_session.session_id not in self.active_sessions)
Copy link
Collaborator

Choose a reason for hiding this comment

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

docstring will be useful here

self.active_sessions[new_session.session_id] = new_session
pass

def diregister_session(self, session):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a typo in the in the method name (diregister)?



def check_tasks_states(self):
print(f"Session: Checking status {self.session_id}, submitted: {len(self.submitted_task_ids)}, received: {len(self.received_task_ids)}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you logging library instead of print please.



def check_tasks_states(self):
print(f"Session: Checking status {self.session_id}, submitted: {len(self.submitted_task_ids)}, received: {len(self.received_task_ids)}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Docstring will be useful here

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.

2 participants