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

Expand Ajax API -- add fetchProjectLogs and fetchflowgraph #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions azkaban/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,22 @@ def get_projects(self):
params={'ajax': 'fetchallprojects'},
))

def get_project_logs(self, name):
"""Get logs of a project.

:param name: Project name.

"""
self._logger.debug('Getting logs of project %s.', name)
return _extract_json(self._request(
method='GET',
endpoint='manager',
params={
'ajax': 'fetchProjectLogs',
'project': name,
},
))

def create_project(self, name, description):
"""Create project.

Expand Down Expand Up @@ -737,6 +753,37 @@ def get_workflow_info(self, name, flow):
# but sends a 200 empty response if the project doesn't exist
raise AzkabanError('Project %s not found.', name)

def get_workflow_graph(self, name, flow):
"""Get graph of jobs corresponding to a workflow.

:param name: Project name.
:param flow: Name of flow in project.

"""
self._logger.debug(
'Fetching flow graph for workflow %s in project %s', flow, name
)
try:
res = self._request(
method='GET',
endpoint='manager',
params={
'ajax': 'fetchflowgraph',
'project': name,
'flow': flow,
},
)
except HTTPError:
Copy link
Owner

Choose a reason for hiding this comment

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

The logic here is the same as in get_workflow_info; do you mind extracting it to a helper function (say _extract_workflow_json)?

# the Azkaban server throws a NullPointerException if the flow doesn't
# exist in the project, which causes a 500 response
raise AzkabanError('Worklow %s not found in project %s.', flow, name)
else:
try:
return _extract_json(res)
except ValueError:
# but sends a 200 empty response if the project doesn't exist
raise AzkabanError('Project %s not found.', name)

def _refresh(self, password=None):
"""Refresh session ID.

Expand Down