Changelog¶
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning
0.4.1 - 2022-02-22¶
Added¶
New connection.upload_file() method that makes sure the argument is point to a valid file, avoiding accidentally attempting to upload a string.
Changed¶
The services.import_ method now has two mutually exclusive arguments for supplying data: path and data. For a given path a check is done to see if it actually points to a valid file on the filesystem for data it is just passed on to upload.
Fixed¶
Some fuctions depending on services.import_ were broken because a check was added to see if the data pointed to a file, not allowing in-memory data to be uploaded, breaking import_dir methods.
0.4.0 - 2022-01-27¶
Fixed¶
Nested SimpleListing failed to recognise correct parent, breaking scan.parameters.add_param
Fixes in xpath and xsi_type resolving
Added¶
xnatpy command-line interface, now xnatpy comes with a number of CLI options to use directly from the shell
A scan.fields shortcut to scan.parameters.add_param for convenience
Objects with custom variables now have the obj.custom_variables property which gives access to the custom variable defined in the interface, including some type casting and value checking when updating them.
0.3.28 - 2021-10-28¶
Fixed¶
Additional parameters were not set properly during object creation
It was impossible to login using tokens because the auth provides could not be found, added workaround
Changed¶
Updated upload_dir and import_dir to default use a SpooledTemporaryFile and improved the zip and tar functionality
0.3.27 - 2021-09-29¶
Added¶
Options to create a session with re-using a JSESSION ID instead of logging in and a BaseXNATSession that does not destroy the session on disconnect
Catalog refresh method for resources
Changed¶
Allow import functions to take project, subject and experiment as xnatpy objects as well as strings
Fixed¶
Failure to connect with redirection when url has a trailing
/
Added an special auth for requests to avoid it automatically reading the netrc and using basic auth, ruining the efficiency from cookie based sessions.
Deleting an object should also remove it from the connection and listing caches
0.3.26 - 2021-04-16¶
Improved¶
Switched to cookie based login instead of basic auth with every requests (should be more performant)
Close underlying requests session when closing a connection
Added CI/CD infrastructure for testing and releasing
Improved import_dicom_inbox
Fixed¶
InvestigatorData had nonsensical string conversion
Option to flatten directories when downloading an entire resource
Bug with resource labels doing unwanted quotation on creation
Added timeouts and caught them on initial requests (before the xnat session was established)
0.3.25 - 2020-09-24¶
Added¶
Added
import_dicom_inbox
function to import dicoms from server filesystem via a pathSupport of querying information for FileData via the containing resource file listing, giving access to file_content, file_format, digest, etc
Fixed¶
Fixed issue when creating objects with a space in the label, the object would be created but the uri with the label (and spaces) would not work, making the return object useless. Now it updates the URI to use the generated ID if possible avoiding the issue.
0.3.24 - 2020-06-19¶
Fixed¶
Stupid import bug in previous release
0.3.23 - 2020-06-19¶
Improved¶
Connections now check if they are still valid and will raise an appropriate error if they are closed. This avoid strange errors when trying to use a connection after
.disconnect
has been called.Avoid warning about collections.abc use on Python 3.7+
0.3.22 - 2020-02-26¶
Added¶
The
services.import_dir
function to import a local directory into XNAT. The function will automatically zip the contents in a temporary file (or memory if desired) before upload.
Changed¶
Updated documentation and setup to refer to new gitlab repository instead of bitbucket, finalizing the move
Add a default timeout of 300 seconds (5 minutes) to all requests to avoid stale connections blocking the entire code (without error, just infinite hangs). Can be changed when connecting or in the XNATSession object afterwards. Note that the 300 seconds is not the total duration of the request allowed, but means that after there is nothing received 300 seconds the connection is considered timed-out, a download that takes 10 minutes would still be possible.
Improved¶
The
import_
function is more resilient. On windows programs like 7zip could mess with the mimetypes and cause zip files get a different estimated content_type. If a non-recognized content type is found, xnatpy will try to re-estimate it based just on the extension.Added supper to change the
import-handler
in theimport_
function
0.3.21 - 2019-10-09¶
Improved¶
Removed annoying warning message when resource was accessed
0.3.20 - 2019-10-09¶
Fixed¶
now possible to create/retrieve data for resources properly. XNAT would only return the catalog when queried and not the object information. Created a work around that catches the case in get_json and retrieves the json data from the listing instead and presents it in a format consistent with the REST API so other code still functions.
0.3.19 - 2019-09-20¶
Added¶
xnatpy changes the user-agent header to give detailed information about the xnatpy client running.
option to have some progress logging/printing added to the download_dir methods for projects and subjects
add method to find specific sessions in the prearchive
Improved¶
Avoid use of get_source when generating xnatpy module code, which should help when compiling xnatpy to a binary (py2exe etc)
0.3.18 - 2019-06-06¶
Improved¶
Added
force
flag toScanData.read_dicom
Added
open
toPrearchiveFile
(same as for FileData)Added
read_dicom
toPrearchiveScan
(same as for ScanData)Documentation improved, added code reference and changelog into docs
Fixed¶
Flag extension_types=False now also working for 1.7 servers
0.3.17 - 2019-04-04¶
Added¶
Can open FileData object with
file.open()
to get a file-like object that can be used similar to a local file.Added
read_dicom()
to ScanData to read the dicom header/file with pydicomexternal_uri
method to get a full external uri of an XNAT object
0.3.16 - 2019-03-28¶
Fixed¶
Support for changing subject and experiment labels
Support creation of ScanData types with the id and type set on creation
Fix a bug in scanning extension types where there are new-lines in the xs:schema tag
0.3.14 - 2019-02-22¶
Added¶
Check which user is logged in and expose that in
connection.logged_in_user
Check the cookies to set the appropriate heartbeat interval for the server.
Allow getting the session expiration information with
connection.session_expiration_time
Changed¶
Refactored some code in the model building, which is optional if you only want to use xnatpy for a convenience layer about requests. Giving
no_build_model=True
to the connect function will disable the scraping of the server xml structure and not create all classes, but will log in and keep alive a connection. Only the simple connectionget
,head
,put
,post
,delete
,download
,upload
methods are really safe to use in that case.XNAT objects (including subject and experiments) will use the listing to get their label and xsitype to avoid the need to get each experiment when creating a listing. This makes listings way more efficient.
Fixed¶
Bug with auth when xnat was not running in the server root, but rather in a subdirectory
0.3.13 - 2019-01-07¶
Fixed¶
Import problem in Python 2 which broke xnatpy
0.3.12 - 2019-01-03¶
Added¶
Adds fields argument to the dicom_dump method to filter on dicom tags server side.
Adds dicom_dump method to prearchive scan.
Allow deleting variables by useing del object.variable, this works in most cases but seem to fail server-side on restriction such as gender (it does not match any valid options)
Changed¶
Beter computation for the uri’s of resources
Fixed¶
Fixed xml deprecation warning due to the use of .getchildren()
0.3.11 - 2018-11-12¶
Fixed¶
Functions with an async parameter had them renamed to asynchronous as async is a keyword as of Python 3.7
Fix a bug in the XSD parsing when an XSD contains a schema-level simpleType
Bug in upload_dir with python3 when using a method based on a temporary file
Added¶
Resource upload methods can now forward kwargs to the
connection.upload
method.Resource constructor also optionally takes a
data_dir
andupload_method
arguments for uploading data immediately after creation.
0.3.10 - 2018-08-31¶
Added¶
The experiment.create_resource and scan.create_resource now take two extra arguments: data_dir and method, which allow the uploading of the content of a directory as the content of the newly created resource. The method is the method for resource.upload_dir method
Command line callable scripts that copies an entire project to another xnat. See
xnat_cp_project --help
Changed¶
Removed wrong default argument for create_assessor (invalid assessor type)
The lower level get/put/post/delete methods now can process full uris as well as paths as long as the uri start matches the server uri (e.g. instead of using /data/projects you can also give https://serveruri.com/data/projects.
Fixed¶
Fixed a small bug where an incorrect error message was giving when not giving a value for the secondary label during object creation.
0.3.9 - 2018-07-02¶
Fixed¶
xnatpy had issues with shared subjects and sessions as the REST API would return the original object (with sharing information in it). Now xnatpy check the requested uri and makes sure the information of the correct project is used. Now shared objects can be used properly in xnatpy.
Added¶
resource.upload now takes an
extract
parameter indicating data should be extracted into files after uploadresource.upload_dir to upload an entire directory to a resource, the directory will be added into the resources so that e.g. directory/a.txt becomes resource/a.txt
redirection detections, if the server has moved and is being redirected (e.g. using a 302 or 301 response), xnatpy will detect that and use the new url instead.
0.3.8 - 2018-06-04¶
Added¶
Methods to retrieve the DICOM header dump using the dcmdump service. This can be used via services.dicom_dump(uri) or experiment.dicom_dump to get the dump of the specific experiment
Fixed¶
Strict username checking after login disabled to avoid problems with OIDC
Fix a bug where token result would contain extra data
0.3.7 - 2018-03-12¶
Fixed¶
Fixed a bug where the prompt for the password on Windows would not work
Changed¶
Hide certificate warnings if verify=False, just give a one time warning that things might not be safe, but no spam at every single request
0.3.6 - 2018-03-09¶
Added¶
Support for issuing tokens in the service module
Fixed¶
Allow user to login using a token (the username check will catch this an allow it)
Changed¶
Improved the logging by reducing spam at the INFO/DEBUG levels. The debug parameter on connect can now be used to enable the logging of xnatpy internals.
Give a specific error if the XNAt password is outdated and requires an update.
0.3.5 - 2018-01-02¶
Fixed¶
There were bugs in the prearchive breaking the entire pre-archive funcationaly
0.3.4 - 2017-11-13¶
Fixed¶
Files in assessors would have a path prefixed with a / in some cases (which should never happen)
0.3.3 - 2017-10-18¶
Changed¶
Abstracted the progress bar for downloading to allow other progress hooks (e.g. GUI)
Fixed¶
Set proper minimal versions for requirements (e.g. six can be too old)
Bug in upload for Python3
Bug with getting the file size when there are redirects (issue #8)
Bug with getting files from a project/subject/experiment/scan directly instead of via resource (issue #5)
0.3.2 - 2017-10-15¶
Fixed¶
Bug in the the create_object function in the selection of the non-history object
Bug in the setting of project properties (due to the lack of a parent)
0.3.1 - 2017-09-04¶
Changed¶
FileData now has an id and path, the id is the filename and the path is the path relative from the resource. This makes working with subdirectories in resources possible.
Fixed¶
Bug where history of XNAT was misinterpreted and an old version of an object could be loaded
Resources could loose track of their ID when the cache was cleared
Resources did not invalidate cache after uploading files
0.3.0 - 2017-08-17¶
Added¶
Better support for complex data structures, especially data types that include lists in their data.
Support for extension types, xnatpy automatically searches for all extension xsd files and will create Python classes for those as well.
Listings can be indexed with integers to get their n-th element, the order is the order given by XNAT.
Allow overwriting of files on upload
Support for listing users via /data/users REST endpoint in the session.users
Changed¶
xsd schema parsing is completely rewritten, allows more support for complex data structures
Fixed¶
Support for XNAT 1.7.3
Fixed a bug where opening a second session would ruin the first one, it should now be possible to have multiple sessions open concurently.
0.2.3 - 2017-04-03¶
Added¶
xnatpy now uses the progressbar2 package to deliver fancy progress bars when downloading
Attributes in the session that allow users to skip/alter the checking of responses
Changed¶
Logging now using a logger. You can change the log levels or supply your own logger which xnatpy will use in favour of its own
xnatpy now gets the version information from 1.7 xnat correctly
Fixed¶
A bug in XNAT 1.7 caused the prearchive routes to be wrong, added a work around that fixes the prearchive with xnatpy