API¶
This is not a complete listing of everything that’s available in reffile_delivery_tools, but rather a summary of
most helpful, or most used items.
instrument_team_tools¶
Instrument teams will find most of their needs satisfied within this one module. The following are the most useful functions
submit_delivery.certify_reffiles(reffile_list, observatory, staging_location)¶certify reference files and save results in a log file,
certify_out.log
Parameters:
- reffile_list (list) – A list of reference files to be certified against CRDS. If only one file needs to be certified, enter it as a one-item list.
- observatory (str) – Either ‘hst’ or ‘jwst’. This is used in setting the correct CRDS server
- staging_location (str) – Either ‘ops’ or ‘test’. This is used in setting the correct CRDS server in conjunction with the observatory. (HST-OPS, HST-TEST, JWST-OPS)
Returns: String output of the certification results.
Example:
from reffile_delivery_tools.instrument_team_tools.submit_delivery import certify_reffiles files_to_deliver = [file1, file2, file3] certify_reffiles(files_to_deliver, 'jwst', 'ops')
submit_delivery.submit_to_redcat(subject, staging_directory, *kwargs)¶Verify, certify and submit a reference file delivery to the ReDCaT Team.
Parameters:
- subject (str) – Subject line of the notification email that’s sent to the ReDCaT Team. Should be a brief description of what’s being delivered.
- staging_directory (str) – Either ‘ops’, ‘test’ or ‘etc’. This determines the destination of the delivery and the creation of the staging area.
- reffile_directory (str) – Directory in which the files to be delivered are stored. Default is the current working directory.
- delivery_form (str) – Name of the delivery form. Default is
delivery_form.txt. The form must be located in the directory with the files that are being delivered.- username (str) – Username for submitting the email. Default is the “log in name” found in the environment. Users should supply a username if the log in name is different from the user’s email username.
- delivery_id (str) – Delivery ID that’s supplied upon successful submission of a delivery to the ReDCaT Team. The ID is found in the delivery form after submitting, as well as in the email notification sent to ReDCaT. Supplying a delivery ID removes the previous submission with that supplied ID before proceeding with the current delivery, and should be used in the case of canceled deliveries which are intended to be replaced. Default is
NoneReturns: None
Examples:
from reffile_delivery_tools.instrument_team_tools.submit_delivery import submit_delivery submit_delivery("New NIRCAM dark files", "ops") # If the current delivery is a resubmission of a canceled delivery with delivery_id=ID: submit_delivery("New NIRCAM dark files", "ops", delivery_id=ID) # removes previous submission
misc.py¶
The misc subpackage contains a number of support modules. The most useful of these for stand-alone use are
jira_handler.py and read_deliveryform.py.
The jira_handler module contains tools for interacting with JIRA.
It is currently fairly limited in scope and is mainly designed around creating or modifying JIRA Issues.
For additional help with the jira-python package, please see their documentation.
- class
jira_handler.JIRAHandler(server, project, *kwargs)¶A class that represents an interaction with a JIRA project in ticket creation and modification.
Parameters:
- server (str) – url of the JIRA server to connect to.
- project (str) – JIRA project key for the project to connect to.
- username (str) – Login username for the JIRA server and project. Default is the “log in name” found in the environment.
- password (str) – Login password for the JIRA server and project. Users should take proper precautions before entering in a password. Default is
None. If no password is given, a prompt will ask for the password.
jira_client¶jira client instance object. For more information, see the jira-python documentation on
JIRA.
issue¶
Noneuntil created via thestart_issuemethod. After an issue is created it can be modified and tracked. See the jira-python documentation onIssue.
project¶Project that the jira client instance is connected to.
start_issue(issue_params)¶Create a new issue.
Parameters: issue_params (dict) – Dictionary of issue fields for creating the issue. See jira-python Issuedocumentation.Returns: None. Assigns the
issueattribute
comment(coment_str)¶Add a comment to the issue.
Parameters: comment_str (str) – Comment string for the issue. Returns: None
attach(filepath)¶Attach a file to the issue.
Parameters: filepath (str) – Path to the file to be attached to the issue Returns: None
link(other_issue_id)¶Link a related JIRA issue.
Parameters: other_issue_id (str) – JIRA issue ID of the issue to be linked. Returns: None Examples:
j = JIRAHandler('https://jira.stsci.edu', 'RFD') # Create an Issue parameters = { 'summary': "COS DISPTAB, TDSTAB", 'description': "New COS DISPTAB and TDSTAB for doing the awesome science", 'issuetype': {'name': "reference file delivery"]}, 'labels': "HST" } j.start_issue(parameters) # Comment on the issue j.comment('I really like this issue.') # Attach a file to the issue j.attach('/path/to/file/to/attach/attachment.txt') # Link an existing issue to the one just created j.link('RFD-40')
The read_deliveryform module contains tools for ingesting and modifying the ReDCaT delivery form.
- class
read_deliveryform.DeliveryForm(delivery_form=raw_form)¶A class that represents a delivery form.
Parameters: delivery_form (str) – Path to the delivery form to be ingested. Default is raw_formwhich is an empty delivery form that’s included with the installation.
form¶Path of the form that was ingested
data¶Python
OrderedDictof keys=questions and values=answers.
write(path=None, clobber=TrueSave changes to a specified file.
Parameters:
- path (str) – Path to which the file will be written. Default is the current working directory.
- clobber (bool) – If
Trueand a file exist with the same name, overwrite. Set toFalseto restrict this behavior.Examples:
empty_form = DeliveryForm() # Initialize a blank form form = DeliveryForm('path/to/filled/in/delivery_form.txt') # Answer/modify a question form.data['1. Name of deliverer'] = Bob # Save the form form.write('/path/to/saved/delivery_form.txt')