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

Added documentation for exporting saved Metric Explorer charts with the XDMoD API #1907

Open
wants to merge 19 commits into
base: xdmod11.0
Choose a base branch
from

Conversation

aestoltm
Copy link
Contributor

@aestoltm aestoltm commented Aug 22, 2024

Description

This documentation contains a Python script that uses the XDMoD API to authenticate with a local XDMoD account for the given credentials and site URL. Then the script will export the saved Metric Explorer charts into the current working directory. This documentation also describes how to edit certain parts of the script and where to find more information about the request schema for the request that exports the images.

Motivation and Context

We received a ticket asking about using the XDMoD API to export saved images for an Open XDMoD - Open OnDemand integration. This documentation will be used with the response and for future tickets that refer to issues about exporting images with the XDMoD API.

Tests performed

Tested script locally.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@aestoltm aestoltm added the documentation Documentation updates label Aug 22, 2024
@aestoltm aestoltm self-assigned this Aug 22, 2024
@aestoltm aestoltm requested a review from connersaeli August 23, 2024 13:19
Copy link
Contributor

@ryanrath ryanrath left a comment

Choose a reason for hiding this comment

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

Just need to add that the user needs to also pip install requests and it'll be good to go.

ryanrath
ryanrath previously approved these changes Aug 23, 2024
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Show resolved Hide resolved
@aestoltm
Copy link
Contributor Author

aestoltm commented Sep 5, 2024

@aaronweeden Updated per your feedback. You can now export either a single chart or all your saved charts to a specified path.

@aestoltm aestoltm requested a review from aaronweeden September 5, 2024 19:02
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
docs/howto-api-image-export.md Show resolved Hide resolved
docs/howto-api-image-export.md Show resolved Hide resolved
docs/howto-api-image-export.md Outdated Show resolved Hide resolved
@aestoltm aestoltm requested a review from aaronweeden September 6, 2024 18:12
@jpwhite4 jpwhite4 added this to the 11.0.0 milestone Sep 10, 2024
@aestoltm aestoltm modified the milestones: 11.0.0, 11.0.1, 11.0.2 Oct 2, 2024
@aestoltm aestoltm changed the base branch from main to xdmod11.0 November 22, 2024 18:59
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f"xdmod_API_export_{idx}.{image_format}"

with open(export_dir + '/' + chart_name, "wb") as f:
f.write(chart_response.content)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f.write(chart_response.content)
f.write(chart_response.content)
print('Wrote ' + export_dir + '/' + chart_name)

Comment on lines 85 to 95
chart_json['operation'] = "get_data"
chart_json['controller_module'] = "metric_explorer"
chart_json['show_title'] = "y"
chart_json['format'] = image_format
chart_json['width'] = width
chart_json['height'] = height

chart_response = session.post(f'{site_address}/controllers/metric_explorer.php', data=chart_json, headers=header)
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f"xdmod_API_export_{idx}.{image_format}"

with open(export_dir + '/' + chart_name, "wb") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
chart_json['operation'] = "get_data"
chart_json['controller_module'] = "metric_explorer"
chart_json['show_title'] = "y"
chart_json['format'] = image_format
chart_json['width'] = width
chart_json['height'] = height
chart_response = session.post(f'{site_address}/controllers/metric_explorer.php', data=chart_json, headers=header)
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f"xdmod_API_export_{idx}.{image_format}"
with open(export_dir + '/' + chart_name, "wb") as f:
chart_json['operation'] = 'get_data'
chart_json['controller_module'] = 'metric_explorer'
chart_json['show_title'] = 'y'
chart_json['format'] = image_format
chart_json['width'] = width
chart_json['height'] = height
chart_response = session.post(f'{site_address}/controllers/metric_explorer.php', data=chart_json, headers=header)
chart_name = f"{chart['name']}.{image_format}" if ('name' in chart) else f'xdmod_API_export_{idx}.{image_format}'
with open(export_dir + '/' + chart_name, 'wb') as f:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants