flywheel-sdk 21.2.0rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flywheel/__init__.py +784 -0
- flywheel/api/__init__.py +46 -0
- flywheel/api/acquisitions_api.py +5014 -0
- flywheel/api/analyses_api.py +3848 -0
- flywheel/api/audit_trail_api.py +568 -0
- flywheel/api/auth_api.py +121 -0
- flywheel/api/batch_api.py +630 -0
- flywheel/api/bulk_api.py +140 -0
- flywheel/api/change_log_api.py +254 -0
- flywheel/api/collections_api.py +3913 -0
- flywheel/api/config_api.py +299 -0
- flywheel/api/container_tasks_api.py +137 -0
- flywheel/api/container_type_api.py +137 -0
- flywheel/api/containers_api.py +4784 -0
- flywheel/api/custom_filters_api.py +466 -0
- flywheel/api/data_view_executions_api.py +549 -0
- flywheel/api/dataexplorer_api.py +1192 -0
- flywheel/api/devices_api.py +1071 -0
- flywheel/api/dimse_api.py +814 -0
- flywheel/api/download_api.py +261 -0
- flywheel/api/files_api.py +1868 -0
- flywheel/api/form_responses_api.py +703 -0
- flywheel/api/gears_api.py +1875 -0
- flywheel/api/groups_api.py +2829 -0
- flywheel/api/jobs_api.py +2320 -0
- flywheel/api/jupyterlab_servers_api.py +245 -0
- flywheel/api/modalities_api.py +562 -0
- flywheel/api/packfiles_api.py +121 -0
- flywheel/api/projects_api.py +7820 -0
- flywheel/api/protocols_api.py +757 -0
- flywheel/api/reports_api.py +1057 -0
- flywheel/api/resolve_api.py +276 -0
- flywheel/api/roles_api.py +563 -0
- flywheel/api/sessions_api.py +5296 -0
- flywheel/api/site_api.py +1552 -0
- flywheel/api/staffing_pools_api.py +677 -0
- flywheel/api/subjects_api.py +5349 -0
- flywheel/api/tasks_api.py +897 -0
- flywheel/api/tree_api.py +266 -0
- flywheel/api/uids_api.py +140 -0
- flywheel/api/upload_api.py +842 -0
- flywheel/api/users_api.py +2142 -0
- flywheel/api/views_api.py +1089 -0
- flywheel/api_client.py +748 -0
- flywheel/client.py +291 -0
- flywheel/configuration.py +308 -0
- flywheel/drone_login.py +65 -0
- flywheel/file_spec.py +67 -0
- flywheel/finder.py +168 -0
- flywheel/flywheel.py +9867 -0
- flywheel/gear_context.py +374 -0
- flywheel/models/__init__.py +726 -0
- flywheel/models/access_level.py +30 -0
- flywheel/models/access_permission.py +197 -0
- flywheel/models/access_permission_output.py +192 -0
- flywheel/models/access_permission_update.py +166 -0
- flywheel/models/access_type.py +54 -0
- flywheel/models/accumulator.py +33 -0
- flywheel/models/acquisition.py +25 -0
- flywheel/models/acquisition_container_output.py +34 -0
- flywheel/models/acquisition_copy_input.py +223 -0
- flywheel/models/acquisition_input.py +297 -0
- flywheel/models/acquisition_list_output.py +767 -0
- flywheel/models/acquisition_modify_input.py +299 -0
- flywheel/models/acquisition_node.py +35 -0
- flywheel/models/acquisition_output.py +767 -0
- flywheel/models/acquisition_parents.py +241 -0
- flywheel/models/acquisition_template_options.py +275 -0
- flywheel/models/acquisition_upsert_input.py +383 -0
- flywheel/models/acquisition_upsert_output.py +243 -0
- flywheel/models/action.py +91 -0
- flywheel/models/adhoc_analysis_input.py +247 -0
- flywheel/models/analysis.py +25 -0
- flywheel/models/analysis_container_output.py +34 -0
- flywheel/models/analysis_files_create_ticket_output.py +241 -0
- flywheel/models/analysis_input.py +310 -0
- flywheel/models/analysis_input_legacy.py +25 -0
- flywheel/models/analysis_list_output.py +680 -0
- flywheel/models/analysis_list_output_inflated_job.py +650 -0
- flywheel/models/analysis_modify_input.py +191 -0
- flywheel/models/analysis_node.py +35 -0
- flywheel/models/analysis_output.py +683 -0
- flywheel/models/analysis_output_inflated_job.py +674 -0
- flywheel/models/analysis_parents.py +270 -0
- flywheel/models/analysis_update.py +25 -0
- flywheel/models/api_key_input_with_optional_label.py +191 -0
- flywheel/models/api_key_output.py +297 -0
- flywheel/models/as_storage.py +298 -0
- flywheel/models/assignee.py +192 -0
- flywheel/models/assignee_type.py +29 -0
- flywheel/models/audit_trail_report.py +486 -0
- flywheel/models/audit_trail_report_status.py +32 -0
- flywheel/models/auth0_auth_out.py +323 -0
- flywheel/models/auth0_options_out.py +319 -0
- flywheel/models/auth_out.py +357 -0
- flywheel/models/auth_session_output.py +272 -0
- flywheel/models/avatars.py +218 -0
- flywheel/models/aws_creds.py +191 -0
- flywheel/models/aws_storage.py +354 -0
- flywheel/models/azure_creds.py +190 -0
- flywheel/models/base_aet.py +245 -0
- flywheel/models/base_compute.py +426 -0
- flywheel/models/batch.py +360 -0
- flywheel/models/batch_cancel_output.py +36 -0
- flywheel/models/batch_create_filters.py +220 -0
- flywheel/models/batch_job_analysis_input.py +281 -0
- flywheel/models/batch_jobs_proposal_input.py +36 -0
- flywheel/models/batch_proposal.py +25 -0
- flywheel/models/batch_proposal_detail.py +36 -0
- flywheel/models/batch_proposal_input.py +25 -0
- flywheel/models/body.py +36 -0
- flywheel/models/body_regenerate_key_api_devices_device_id_key_post.py +25 -0
- flywheel/models/body_region.py +46 -0
- flywheel/models/bookmark.py +189 -0
- flywheel/models/bulk_move_input.py +272 -0
- flywheel/models/bulk_move_sessions.py +25 -0
- flywheel/models/callbacks_virus_scan_input.py +36 -0
- flywheel/models/cancelled_batch_output.py +163 -0
- flywheel/models/catalog_list_output.py +407 -0
- flywheel/models/central_out.py +299 -0
- flywheel/models/change.py +379 -0
- flywheel/models/change_log_container_type.py +38 -0
- flywheel/models/change_log_document.py +245 -0
- flywheel/models/change_method.py +33 -0
- flywheel/models/classic_batch_job_output.py +352 -0
- flywheel/models/classic_batch_job_output_inflated_jobs.py +379 -0
- flywheel/models/classic_batch_proposal_input.py +388 -0
- flywheel/models/classic_batch_proposal_output.py +471 -0
- flywheel/models/classification_add_delete.py +36 -0
- flywheel/models/classification_replace.py +36 -0
- flywheel/models/classification_update_input.py +36 -0
- flywheel/models/cohort.py +29 -0
- flywheel/models/collection.py +25 -0
- flywheel/models/collection_container_output.py +32 -0
- flywheel/models/collection_input.py +217 -0
- flywheel/models/collection_input_with_contents.py +248 -0
- flywheel/models/collection_node.py +192 -0
- flywheel/models/collection_node_level.py +31 -0
- flywheel/models/collection_operation.py +193 -0
- flywheel/models/collection_operation_type.py +29 -0
- flywheel/models/collection_output.py +639 -0
- flywheel/models/collection_with_stats.py +637 -0
- flywheel/models/column.py +286 -0
- flywheel/models/column_type.py +32 -0
- flywheel/models/common_classification.py +135 -0
- flywheel/models/common_deleted_count.py +25 -0
- flywheel/models/common_editions.py +25 -0
- flywheel/models/common_info.py +135 -0
- flywheel/models/common_join_origins.py +25 -0
- flywheel/models/common_key.py +36 -0
- flywheel/models/common_modified_count.py +25 -0
- flywheel/models/common_object_created.py +36 -0
- flywheel/models/common_project_settings.py +25 -0
- flywheel/models/common_settings.py +36 -0
- flywheel/models/complete_multipart_upload_output.py +189 -0
- flywheel/models/complete_s3_multipart_upload_input.py +241 -0
- flywheel/models/config_feature_map.py +36 -0
- flywheel/models/config_out.py +381 -0
- flywheel/models/config_output.py +36 -0
- flywheel/models/config_site_config_output.py +36 -0
- flywheel/models/config_site_settings.py +36 -0
- flywheel/models/config_site_settings_input.py +36 -0
- flywheel/models/conflict_types.py +30 -0
- flywheel/models/container_delete_reason.py +39 -0
- flywheel/models/container_filter.py +193 -0
- flywheel/models/container_id_view_input.py +521 -0
- flywheel/models/container_id_view_input_execute_and_save.py +308 -0
- flywheel/models/container_modify.py +536 -0
- flywheel/models/container_new_output.py +25 -0
- flywheel/models/container_node_min.py +350 -0
- flywheel/models/container_output.py +36 -0
- flywheel/models/container_output_with_files.py +283 -0
- flywheel/models/container_parents.py +311 -0
- flywheel/models/container_pipeline_input.py +536 -0
- flywheel/models/container_project_parents.py +25 -0
- flywheel/models/container_reference.py +193 -0
- flywheel/models/container_reference_with_label.py +219 -0
- flywheel/models/container_session_parents.py +25 -0
- flywheel/models/container_subject_parents.py +25 -0
- flywheel/models/container_type.py +39 -0
- flywheel/models/container_uidcheck.py +253 -0
- flywheel/models/container_update.py +135 -0
- flywheel/models/context_input.py +217 -0
- flywheel/models/copy_filter.py +299 -0
- flywheel/models/copy_status.py +32 -0
- flywheel/models/core_models_api_key_api_key_input.py +190 -0
- flywheel/models/core_models_audit_trail_create_report_input.py +273 -0
- flywheel/models/core_models_audit_trail_modify_report_input.py +167 -0
- flywheel/models/core_models_common_source.py +189 -0
- flywheel/models/core_models_jobs_api_key_input.py +191 -0
- flywheel/models/core_models_search_parent_type.py +33 -0
- flywheel/models/core_workflows_form_responses_models_form_parents.py +163 -0
- flywheel/models/core_workflows_form_responses_models_form_response_output.py +440 -0
- flywheel/models/core_workflows_reader_models_reader_task_parents.py +295 -0
- flywheel/models/creds.py +135 -0
- flywheel/models/curator.py +221 -0
- flywheel/models/current_user_output.py +707 -0
- flywheel/models/custom_field.py +437 -0
- flywheel/models/custom_form.py +244 -0
- flywheel/models/cvat_info.py +275 -0
- flywheel/models/cvat_settings.py +272 -0
- flywheel/models/cvat_settings_input.py +272 -0
- flywheel/models/cvat_sync_state.py +30 -0
- flywheel/models/daily_report_usage.py +565 -0
- flywheel/models/data_strategy.py +29 -0
- flywheel/models/data_view.py +25 -0
- flywheel/models/data_view_analysis_file_spec.py +221 -0
- flywheel/models/data_view_analysis_filter_spec.py +221 -0
- flywheel/models/data_view_column_alias.py +337 -0
- flywheel/models/data_view_column_spec.py +286 -0
- flywheel/models/data_view_execution.py +505 -0
- flywheel/models/data_view_execution_state.py +31 -0
- flywheel/models/data_view_file_spec.py +392 -0
- flywheel/models/data_view_group_by.py +166 -0
- flywheel/models/data_view_group_by_column.py +194 -0
- flywheel/models/data_view_name_filter_spec.py +194 -0
- flywheel/models/data_view_output.py +25 -0
- flywheel/models/data_view_save_data_view_input.py +25 -0
- flywheel/models/data_view_zip_filter_spec.py +223 -0
- flywheel/models/default_flywheel_role.py +30 -0
- flywheel/models/deid_log_skip_reason.py +29 -0
- flywheel/models/delete_by_search_query.py +253 -0
- flywheel/models/deleted_file.py +514 -0
- flywheel/models/deleted_result.py +194 -0
- flywheel/models/deprecated_action.py +29 -0
- flywheel/models/destination_container_type.py +30 -0
- flywheel/models/device.py +437 -0
- flywheel/models/device_admin_update.py +194 -0
- flywheel/models/device_create.py +219 -0
- flywheel/models/device_self_update.py +272 -0
- flywheel/models/device_status.py +36 -0
- flywheel/models/device_status_entry.py +221 -0
- flywheel/models/device_storage_strategy_update.py +193 -0
- flywheel/models/dimse_project_input.py +36 -0
- flywheel/models/dimse_project_output.py +36 -0
- flywheel/models/dimse_service_input.py +36 -0
- flywheel/models/dimse_service_output.py +36 -0
- flywheel/models/download.py +249 -0
- flywheel/models/download_container_filter.py +167 -0
- flywheel/models/download_container_filter_definition.py +222 -0
- flywheel/models/download_filter.py +221 -0
- flywheel/models/download_filter_definition.py +195 -0
- flywheel/models/download_format.py +29 -0
- flywheel/models/download_input.py +25 -0
- flywheel/models/download_node.py +189 -0
- flywheel/models/download_strategy.py +31 -0
- flywheel/models/download_ticket.py +36 -0
- flywheel/models/download_ticket_stub.py +249 -0
- flywheel/models/download_ticket_with_summary.py +36 -0
- flywheel/models/e_signature.py +242 -0
- flywheel/models/edition.py +169 -0
- flywheel/models/egress_device.py +597 -0
- flywheel/models/egress_device_page.py +219 -0
- flywheel/models/egress_provider.py +408 -0
- flywheel/models/egress_provider_id.py +164 -0
- flywheel/models/exchange_storage.py +243 -0
- flywheel/models/executor_info.py +353 -0
- flywheel/models/export_templates.py +195 -0
- flywheel/models/features.py +1838 -0
- flywheel/models/field_change.py +271 -0
- flywheel/models/field_change_log_document.py +245 -0
- flywheel/models/field_type.py +37 -0
- flywheel/models/file.py +1139 -0
- flywheel/models/file_classification_delta.py +245 -0
- flywheel/models/file_container_type.py +34 -0
- flywheel/models/file_entry.py +740 -0
- flywheel/models/file_export_templates.py +272 -0
- flywheel/models/file_format.py +33 -0
- flywheel/models/file_gear_info.py +215 -0
- flywheel/models/file_group.py +29 -0
- flywheel/models/file_list_output.py +1115 -0
- flywheel/models/file_modify_input.py +191 -0
- flywheel/models/file_move_input.py +221 -0
- flywheel/models/file_node.py +1138 -0
- flywheel/models/file_node_min.py +321 -0
- flywheel/models/file_origin.py +283 -0
- flywheel/models/file_output.py +1135 -0
- flywheel/models/file_parents.py +297 -0
- flywheel/models/file_reference.py +221 -0
- flywheel/models/file_suggestion.py +241 -0
- flywheel/models/file_template_options.py +299 -0
- flywheel/models/file_upsert_input.py +612 -0
- flywheel/models/file_upsert_origin.py +36 -0
- flywheel/models/file_upsert_output.py +1154 -0
- flywheel/models/file_version.py +190 -0
- flywheel/models/file_version_copy_of.py +273 -0
- flywheel/models/file_version_output.py +325 -0
- flywheel/models/file_via.py +245 -0
- flywheel/models/file_zip_entry.py +25 -0
- flywheel/models/file_zip_info.py +25 -0
- flywheel/models/filter.py +350 -0
- flywheel/models/filter_input.py +218 -0
- flywheel/models/filter_values.py +195 -0
- flywheel/models/filter_view.py +28 -0
- flywheel/models/fixed_file_version_input.py +216 -0
- flywheel/models/fixed_input.py +299 -0
- flywheel/models/form_definition.py +163 -0
- flywheel/models/form_response_base.py +311 -0
- flywheel/models/form_response_create.py +193 -0
- flywheel/models/gcp_creds.py +397 -0
- flywheel/models/gcp_storage.py +298 -0
- flywheel/models/gear.py +619 -0
- flywheel/models/gear_category.py +32 -0
- flywheel/models/gear_config.py +138 -0
- flywheel/models/gear_context_input.py +164 -0
- flywheel/models/gear_context_lookup.py +25 -0
- flywheel/models/gear_context_lookup_item.py +36 -0
- flywheel/models/gear_context_value_output.py +272 -0
- flywheel/models/gear_context_value_output_unfound.py +164 -0
- flywheel/models/gear_custom.py +135 -0
- flywheel/models/gear_directive.py +135 -0
- flywheel/models/gear_doc.py +25 -0
- flywheel/models/gear_document.py +332 -0
- flywheel/models/gear_document_input.py +303 -0
- flywheel/models/gear_document_legacy_input.py +302 -0
- flywheel/models/gear_environment.py +135 -0
- flywheel/models/gear_exchange.py +221 -0
- flywheel/models/gear_file_input.py +192 -0
- flywheel/models/gear_id_output.py +170 -0
- flywheel/models/gear_info.py +251 -0
- flywheel/models/gear_input_item.py +231 -0
- flywheel/models/gear_inputs.py +140 -0
- flywheel/models/gear_invocation.py +138 -0
- flywheel/models/gear_key_input.py +191 -0
- flywheel/models/gear_manifest.py +624 -0
- flywheel/models/gear_mixin.py +218 -0
- flywheel/models/gear_node.py +355 -0
- flywheel/models/gear_output_configuration.py +164 -0
- flywheel/models/gear_permissions.py +191 -0
- flywheel/models/gear_permissions_input.py +163 -0
- flywheel/models/gear_permissions_type.py +29 -0
- flywheel/models/gear_return_ticket.py +25 -0
- flywheel/models/gear_rule.py +653 -0
- flywheel/models/gear_rule_condition.py +219 -0
- flywheel/models/gear_rule_condition_type.py +37 -0
- flywheel/models/gear_rule_input.py +517 -0
- flywheel/models/gear_rule_modify_input.py +492 -0
- flywheel/models/gear_rule_output.py +652 -0
- flywheel/models/gear_save_submission.py +221 -0
- flywheel/models/gear_series.py +298 -0
- flywheel/models/gear_series_update.py +163 -0
- flywheel/models/gear_suggestion_output.py +301 -0
- flywheel/models/gear_ticket.py +245 -0
- flywheel/models/gear_ticket_output.py +163 -0
- flywheel/models/google_auth_out.py +299 -0
- flywheel/models/graph_filter.py +329 -0
- flywheel/models/group.py +25 -0
- flywheel/models/group_by.py +163 -0
- flywheel/models/group_by_column.py +36 -0
- flywheel/models/group_container_output.py +33 -0
- flywheel/models/group_input.py +248 -0
- flywheel/models/group_metadata_input.py +36 -0
- flywheel/models/group_node.py +34 -0
- flywheel/models/group_output.py +471 -0
- flywheel/models/group_report.py +218 -0
- flywheel/models/group_role.py +163 -0
- flywheel/models/group_settings_output.py +249 -0
- flywheel/models/group_update.py +249 -0
- flywheel/models/header_feature.py +37 -0
- flywheel/models/hierarchy_export_templates.py +272 -0
- flywheel/models/http_validation_error.py +167 -0
- flywheel/models/info.py +218 -0
- flywheel/models/info_add_remove.py +36 -0
- flywheel/models/info_container_type.py +35 -0
- flywheel/models/info_replace.py +36 -0
- flywheel/models/info_update_input.py +36 -0
- flywheel/models/ingress_provider.py +299 -0
- flywheel/models/ingress_providers.py +272 -0
- flywheel/models/ingress_site_settings.py +305 -0
- flywheel/models/ingress_update_provider.py +218 -0
- flywheel/models/inline_response200.py +163 -0
- flywheel/models/inline_response2001.py +171 -0
- flywheel/models/inline_response2002.py +163 -0
- flywheel/models/inline_response2003.py +36 -0
- flywheel/models/inline_response2005.py +25 -0
- flywheel/models/input_filter.py +221 -0
- flywheel/models/input_job.py +521 -0
- flywheel/models/input_job_profile.py +275 -0
- flywheel/models/inserted_id.py +163 -0
- flywheel/models/job.py +841 -0
- flywheel/models/job_analysis_input.py +273 -0
- flywheel/models/job_ask.py +301 -0
- flywheel/models/job_ask_response.py +195 -0
- flywheel/models/job_ask_response_job.py +978 -0
- flywheel/models/job_ask_return.py +25 -0
- flywheel/models/job_ask_return_criteria.py +245 -0
- flywheel/models/job_ask_state.py +25 -0
- flywheel/models/job_ask_state_response.py +163 -0
- flywheel/models/job_complete.py +220 -0
- flywheel/models/job_completion_input.py +25 -0
- flywheel/models/job_completion_ticket.py +25 -0
- flywheel/models/job_config.py +135 -0
- flywheel/models/job_config_input.py +272 -0
- flywheel/models/job_config_inputs.py +25 -0
- flywheel/models/job_config_output.py +25 -0
- flywheel/models/job_container_detail.py +25 -0
- flywheel/models/job_destination.py +189 -0
- flywheel/models/job_detail.py +925 -0
- flywheel/models/job_detail_container.py +190 -0
- flywheel/models/job_detail_file_entry.py +194 -0
- flywheel/models/job_detail_group.py +190 -0
- flywheel/models/job_detail_parent_info.py +303 -0
- flywheel/models/job_executor_info.py +369 -0
- flywheel/models/job_file_input.py +247 -0
- flywheel/models/job_file_input_list_output.py +247 -0
- flywheel/models/job_file_object.py +435 -0
- flywheel/models/job_file_object_list_output.py +407 -0
- flywheel/models/job_gear_match.py +25 -0
- flywheel/models/job_inputs_array_item.py +305 -0
- flywheel/models/job_inputs_item.py +242 -0
- flywheel/models/job_inputs_object.py +138 -0
- flywheel/models/job_list_entry.py +25 -0
- flywheel/models/job_list_output.py +979 -0
- flywheel/models/job_list_output_config.py +220 -0
- flywheel/models/job_log.py +189 -0
- flywheel/models/job_log_column.py +40 -0
- flywheel/models/job_log_record.py +192 -0
- flywheel/models/job_modify.py +193 -0
- flywheel/models/job_origin.py +190 -0
- flywheel/models/job_output.py +1005 -0
- flywheel/models/job_output_config.py +247 -0
- flywheel/models/job_parents.py +297 -0
- flywheel/models/job_priority.py +31 -0
- flywheel/models/job_priority_update.py +192 -0
- flywheel/models/job_profile.py +427 -0
- flywheel/models/job_profile_input.py +25 -0
- flywheel/models/job_request.py +221 -0
- flywheel/models/job_request_item.py +246 -0
- flywheel/models/job_request_item_type.py +31 -0
- flywheel/models/job_request_target.py +270 -0
- flywheel/models/job_state.py +32 -0
- flywheel/models/job_state_counts.py +25 -0
- flywheel/models/job_stats_by_state.py +25 -0
- flywheel/models/job_ticket_output.py +165 -0
- flywheel/models/job_transition_times.py +253 -0
- flywheel/models/job_version_info.py +135 -0
- flywheel/models/jobs_by_state.py +272 -0
- flywheel/models/jobs_list.py +166 -0
- flywheel/models/join_origin_device.py +164 -0
- flywheel/models/join_origin_job.py +219 -0
- flywheel/models/join_origin_user.py +189 -0
- flywheel/models/join_origins.py +223 -0
- flywheel/models/join_type.py +28 -0
- flywheel/models/jupyterhub_workspace.py +163 -0
- flywheel/models/jupyterlab_server_modify.py +275 -0
- flywheel/models/jupyterlab_server_origin.py +25 -0
- flywheel/models/jupyterlab_server_output.py +25 -0
- flywheel/models/jupyterlab_server_response.py +415 -0
- flywheel/models/jupyterlab_server_update.py +25 -0
- flywheel/models/ldap_sync.py +36 -0
- flywheel/models/ldap_sync_config.py +163 -0
- flywheel/models/ldap_sync_input.py +36 -0
- flywheel/models/ldap_sync_status.py +250 -0
- flywheel/models/legacy_api_key_output.py +271 -0
- flywheel/models/legacy_input.py +244 -0
- flywheel/models/legacy_usage_report.py +309 -0
- flywheel/models/legacys_usage_project_entry.py +194 -0
- flywheel/models/libs_workflows_models_parent_type.py +33 -0
- flywheel/models/libs_workflows_models_task_status.py +32 -0
- flywheel/models/local_storage.py +217 -0
- flywheel/models/location.py +189 -0
- flywheel/models/locked.py +219 -0
- flywheel/models/master_subject_code_dob_input.py +279 -0
- flywheel/models/master_subject_code_input.py +281 -0
- flywheel/models/master_subject_code_output.py +166 -0
- flywheel/models/matched_acquisition_output.py +518 -0
- flywheel/models/mfa_channel.py +30 -0
- flywheel/models/mfa_settings.py +167 -0
- flywheel/models/mixins.py +794 -0
- flywheel/models/ml_set_filter.py +194 -0
- flywheel/models/ml_type.py +30 -0
- flywheel/models/modality.py +250 -0
- flywheel/models/modality_input.py +244 -0
- flywheel/models/modality_modify.py +218 -0
- flywheel/models/modality_output.py +271 -0
- flywheel/models/modified_result.py +190 -0
- flywheel/models/modify_user_input.py +466 -0
- flywheel/models/move_conflict.py +300 -0
- flywheel/models/note.py +391 -0
- flywheel/models/note_input.py +165 -0
- flywheel/models/optional_input_policy.py +30 -0
- flywheel/models/order.py +29 -0
- flywheel/models/organ_system.py +64 -0
- flywheel/models/origin.py +193 -0
- flywheel/models/origin_type.py +35 -0
- flywheel/models/orphaned_count.py +163 -0
- flywheel/models/output_user_page.py +219 -0
- flywheel/models/packfile_cleanup_output.py +166 -0
- flywheel/models/packfile_removed_output.py +189 -0
- flywheel/models/page.py +216 -0
- flywheel/models/page_generic_file_output.py +219 -0
- flywheel/models/page_generic_filter.py +219 -0
- flywheel/models/page_generic_form_response_output.py +219 -0
- flywheel/models/page_generic_protocol.py +244 -0
- flywheel/models/page_generic_reader_task_output.py +244 -0
- flywheel/models/page_generic_staffing_pool.py +244 -0
- flywheel/models/parsed_query_response.py +194 -0
- flywheel/models/permission_access_permission.py +25 -0
- flywheel/models/premade_jobs_batch_job_output.py +298 -0
- flywheel/models/premade_jobs_batch_job_output_inflated_jobs.py +299 -0
- flywheel/models/premade_jobs_batch_proposal.py +334 -0
- flywheel/models/premade_jobs_batch_proposal_detail.py +166 -0
- flywheel/models/premade_jobs_batch_proposal_input.py +166 -0
- flywheel/models/project.py +25 -0
- flywheel/models/project_acquisition_upsert_input.py +25 -0
- flywheel/models/project_acquisition_upsert_output.py +25 -0
- flywheel/models/project_aet.py +331 -0
- flywheel/models/project_aet_input.py +248 -0
- flywheel/models/project_catalog_list_output.py +25 -0
- flywheel/models/project_contact.py +194 -0
- flywheel/models/project_container_output.py +41 -0
- flywheel/models/project_copy_input.py +245 -0
- flywheel/models/project_copy_output.py +215 -0
- flywheel/models/project_counters.py +346 -0
- flywheel/models/project_hierarchy_input.py +278 -0
- flywheel/models/project_hierarchy_output.py +222 -0
- flywheel/models/project_hierarchy_upsert_input.py +25 -0
- flywheel/models/project_hierarchy_upsert_output.py +25 -0
- flywheel/models/project_input.py +384 -0
- flywheel/models/project_institution.py +194 -0
- flywheel/models/project_list_output.py +897 -0
- flywheel/models/project_locking_reason.py +32 -0
- flywheel/models/project_modify.py +413 -0
- flywheel/models/project_node.py +42 -0
- flywheel/models/project_output.py +899 -0
- flywheel/models/project_parents.py +168 -0
- flywheel/models/project_report.py +463 -0
- flywheel/models/project_report_list.py +167 -0
- flywheel/models/project_session_upsert_input.py +25 -0
- flywheel/models/project_session_upsert_output.py +25 -0
- flywheel/models/project_settings_input.py +333 -0
- flywheel/models/project_settings_output.py +333 -0
- flywheel/models/project_settings_sharing.py +327 -0
- flywheel/models/project_settings_sharing_input.py +334 -0
- flywheel/models/project_settings_workspaces.py +167 -0
- flywheel/models/project_settings_workspaces_input.py +167 -0
- flywheel/models/project_share_level.py +29 -0
- flywheel/models/project_sharing_settings_project_contact.py +25 -0
- flywheel/models/project_sharing_settings_project_counters.py +36 -0
- flywheel/models/project_sharing_settings_project_institution.py +25 -0
- flywheel/models/project_sharing_settings_project_settings_input.py +25 -0
- flywheel/models/project_sharing_settings_project_settings_output.py +25 -0
- flywheel/models/project_sharing_settings_project_settings_sharing.py +25 -0
- flywheel/models/project_sharing_settings_project_settings_sharing_input.py +25 -0
- flywheel/models/project_sharing_settings_project_stats.py +36 -0
- flywheel/models/project_stats.py +270 -0
- flywheel/models/project_subject_upsert_input.py +25 -0
- flywheel/models/project_subject_upsert_output.py +25 -0
- flywheel/models/project_template.py +195 -0
- flywheel/models/project_template_input.py +195 -0
- flywheel/models/project_template_list_input.py +166 -0
- flywheel/models/project_template_requirement.py +36 -0
- flywheel/models/project_template_session_template.py +36 -0
- flywheel/models/project_upsert_origin.py +36 -0
- flywheel/models/protocol.py +515 -0
- flywheel/models/protocol_e_signature_config.py +191 -0
- flywheel/models/protocol_input.py +354 -0
- flywheel/models/protocol_modify.py +277 -0
- flywheel/models/protocol_status.py +30 -0
- flywheel/models/provider.py +461 -0
- flywheel/models/provider_access_type.py +29 -0
- flywheel/models/provider_class.py +29 -0
- flywheel/models/provider_deletion_status.py +189 -0
- flywheel/models/provider_input.py +25 -0
- flywheel/models/provider_links.py +282 -0
- flywheel/models/provider_type.py +34 -0
- flywheel/models/providers.py +277 -0
- flywheel/models/reader_batch_create.py +463 -0
- flywheel/models/reader_task.py +725 -0
- flywheel/models/reader_task_config.py +189 -0
- flywheel/models/reader_task_create.py +543 -0
- flywheel/models/reader_task_modify.py +303 -0
- flywheel/models/reader_task_output.py +752 -0
- flywheel/models/reader_task_parent_details.py +322 -0
- flywheel/models/report_access_log_context.py +301 -0
- flywheel/models/report_access_log_context_entry.py +194 -0
- flywheel/models/report_access_log_context_file_entry.py +165 -0
- flywheel/models/report_access_log_entry.py +624 -0
- flywheel/models/report_access_log_origin.py +194 -0
- flywheel/models/report_availability_list.py +167 -0
- flywheel/models/report_daily_usage_entry.py +501 -0
- flywheel/models/report_demographics_grid.py +36 -0
- flywheel/models/report_ethnicity_grid.py +252 -0
- flywheel/models/report_gender_count.py +222 -0
- flywheel/models/report_group_report.py +217 -0
- flywheel/models/report_legacy_usage_entry.py +36 -0
- flywheel/models/report_legacy_usage_project_entry.py +36 -0
- flywheel/models/report_project.py +25 -0
- flywheel/models/report_site.py +192 -0
- flywheel/models/report_time_period.py +193 -0
- flywheel/models/report_usage.py +630 -0
- flywheel/models/report_usage_entry.py +25 -0
- flywheel/models/resolve_input.py +163 -0
- flywheel/models/resolve_output.py +194 -0
- flywheel/models/resolver_acquisition_node.py +36 -0
- flywheel/models/resolver_analysis_node.py +36 -0
- flywheel/models/resolver_file_node.py +36 -0
- flywheel/models/resolver_gear_node.py +36 -0
- flywheel/models/resolver_group_node.py +36 -0
- flywheel/models/resolver_input.py +25 -0
- flywheel/models/resolver_node.py +182 -0
- flywheel/models/resolver_output.py +25 -0
- flywheel/models/resolver_project_node.py +36 -0
- flywheel/models/resolver_session_node.py +36 -0
- flywheel/models/resolver_subject_node.py +36 -0
- flywheel/models/role_input.py +192 -0
- flywheel/models/role_output.py +273 -0
- flywheel/models/role_permission.py +194 -0
- flywheel/models/role_permission_output.py +189 -0
- flywheel/models/role_permission_update.py +163 -0
- flywheel/models/role_type.py +32 -0
- flywheel/models/role_update.py +194 -0
- flywheel/models/roles_backwards_compatible_role_assignment.py +36 -0
- flywheel/models/roles_group_role_pool_input.py +36 -0
- flywheel/models/roles_role.py +36 -0
- flywheel/models/roles_role_assignment.py +195 -0
- flywheel/models/roles_role_input.py +36 -0
- flywheel/models/rule.py +467 -0
- flywheel/models/rule_any.py +216 -0
- flywheel/models/s3_addressing_style.py +29 -0
- flywheel/models/s3_compat_storage.py +381 -0
- flywheel/models/save_search.py +298 -0
- flywheel/models/save_search_input.py +219 -0
- flywheel/models/save_search_output.py +301 -0
- flywheel/models/save_search_page.py +219 -0
- flywheel/models/save_search_parent.py +192 -0
- flywheel/models/save_search_update.py +194 -0
- flywheel/models/search_acquisition_response.py +252 -0
- flywheel/models/search_analysis_response.py +254 -0
- flywheel/models/search_collection_response.py +254 -0
- flywheel/models/search_file_response.py +312 -0
- flywheel/models/search_group_response.py +196 -0
- flywheel/models/search_parent_acquisition.py +47 -0
- flywheel/models/search_parent_analysis.py +47 -0
- flywheel/models/search_parent_collection.py +46 -0
- flywheel/models/search_parent_project.py +54 -0
- flywheel/models/search_parent_response.py +213 -0
- flywheel/models/search_parent_session.py +48 -0
- flywheel/models/search_parent_subject.py +48 -0
- flywheel/models/search_parse_error.py +252 -0
- flywheel/models/search_parse_search_query_result.py +36 -0
- flywheel/models/search_project_response.py +196 -0
- flywheel/models/search_query.py +337 -0
- flywheel/models/search_query_suggestions.py +36 -0
- flywheel/models/search_response.py +448 -0
- flywheel/models/search_return_type.py +33 -0
- flywheel/models/search_save_search.py +36 -0
- flywheel/models/search_save_search_input.py +36 -0
- flywheel/models/search_save_search_parent.py +36 -0
- flywheel/models/search_save_search_update.py +36 -0
- flywheel/models/search_session_response.py +252 -0
- flywheel/models/search_status.py +166 -0
- flywheel/models/search_structured_search_query.py +25 -0
- flywheel/models/search_subject_response.py +225 -0
- flywheel/models/search_suggestion.py +36 -0
- flywheel/models/select_item.py +190 -0
- flywheel/models/server_state.py +303 -0
- flywheel/models/service_aet.py +301 -0
- flywheel/models/service_aet_input.py +276 -0
- flywheel/models/session.py +25 -0
- flywheel/models/session_container_output.py +35 -0
- flywheel/models/session_copy_input.py +253 -0
- flywheel/models/session_embedded_subject.py +299 -0
- flywheel/models/session_input.py +431 -0
- flywheel/models/session_list_output.py +897 -0
- flywheel/models/session_metadata_input.py +36 -0
- flywheel/models/session_modify.py +464 -0
- flywheel/models/session_node.py +36 -0
- flywheel/models/session_output.py +897 -0
- flywheel/models/session_parents.py +220 -0
- flywheel/models/session_template_options.py +221 -0
- flywheel/models/session_template_recalc_output.py +165 -0
- flywheel/models/session_upsert_input.py +464 -0
- flywheel/models/session_upsert_output.py +243 -0
- flywheel/models/sharing_filter_options.py +345 -0
- flywheel/models/signed_fs_upload_output.py +189 -0
- flywheel/models/signed_url_cleanup_input.py +189 -0
- flywheel/models/signed_url_upload_input.py +190 -0
- flywheel/models/signed_url_upload_output.py +349 -0
- flywheel/models/site.py +623 -0
- flywheel/models/site_report.py +194 -0
- flywheel/models/site_settings.py +385 -0
- flywheel/models/sort.py +192 -0
- flywheel/models/stable_api_key_input.py +25 -0
- flywheel/models/staffing_pool.py +324 -0
- flywheel/models/staffing_pool_create.py +216 -0
- flywheel/models/staffing_pool_list.py +164 -0
- flywheel/models/staffing_pool_modify.py +218 -0
- flywheel/models/state.py +32 -0
- flywheel/models/static_compute.py +218 -0
- flywheel/models/status_transitions.py +245 -0
- flywheel/models/status_type.py +31 -0
- flywheel/models/status_value.py +31 -0
- flywheel/models/storage_strategy.py +30 -0
- flywheel/models/storage_strategy_config.py +194 -0
- flywheel/models/structured_query.py +165 -0
- flywheel/models/structured_query_suggestions.py +196 -0
- flywheel/models/structured_query_value_suggestion.py +247 -0
- flywheel/models/subject.py +34 -0
- flywheel/models/subject_container_output.py +36 -0
- flywheel/models/subject_copy_input.py +223 -0
- flywheel/models/subject_input.py +627 -0
- flywheel/models/subject_modify.py +684 -0
- flywheel/models/subject_node.py +37 -0
- flywheel/models/subject_output.py +1008 -0
- flywheel/models/subject_output_for_list.py +1005 -0
- flywheel/models/subject_parents.py +194 -0
- flywheel/models/subject_role_permission.py +194 -0
- flywheel/models/subject_state.py +30 -0
- flywheel/models/subject_template_options.py +191 -0
- flywheel/models/subject_upsert_input.py +573 -0
- flywheel/models/subject_upsert_output.py +216 -0
- flywheel/models/sync_user_input.py +322 -0
- flywheel/models/tag.py +165 -0
- flywheel/models/task_assign.py +194 -0
- flywheel/models/task_facet.py +29 -0
- flywheel/models/task_parent_ref.py +245 -0
- flywheel/models/task_parent_ref_input.py +219 -0
- flywheel/models/task_priority.py +31 -0
- flywheel/models/task_submission.py +189 -0
- flywheel/models/therapeutic_area.py +60 -0
- flywheel/models/transitions.py +272 -0
- flywheel/models/tree_container_request_spec.py +281 -0
- flywheel/models/tree_graph.py +142 -0
- flywheel/models/tree_graph_connection.py +244 -0
- flywheel/models/tree_graph_connections.py +142 -0
- flywheel/models/tree_graph_node.py +166 -0
- flywheel/models/tree_request.py +25 -0
- flywheel/models/tree_response_item.py +142 -0
- flywheel/models/type_str.py +31 -0
- flywheel/models/uid_check_input_acquisitions.py +244 -0
- flywheel/models/uid_check_input_sessions.py +244 -0
- flywheel/models/uid_check_output.py +191 -0
- flywheel/models/upload_complete_s3_multipart_input.py +25 -0
- flywheel/models/upload_complete_s3_multipart_output.py +25 -0
- flywheel/models/upload_signed_fs_file_upload_output.py +36 -0
- flywheel/models/upload_signed_upload_url_input.py +36 -0
- flywheel/models/upload_signed_upload_url_output.py +36 -0
- flywheel/models/upload_ticket_output.py +215 -0
- flywheel/models/upload_token_output.py +163 -0
- flywheel/models/upsert_result.py +31 -0
- flywheel/models/user.py +760 -0
- flywheel/models/user_api_key.py +220 -0
- flywheel/models/user_input.py +461 -0
- flywheel/models/user_jobs.py +219 -0
- flywheel/models/user_jobs_output.py +25 -0
- flywheel/models/user_output.py +36 -0
- flywheel/models/user_output_id.py +163 -0
- flywheel/models/user_preferences.py +135 -0
- flywheel/models/user_wechat.py +135 -0
- flywheel/models/validation_error.py +215 -0
- flywheel/models/validation_rule.py +190 -0
- flywheel/models/version.py +363 -0
- flywheel/models/version_output.py +25 -0
- flywheel/models/view_id_output.py +164 -0
- flywheel/models/view_output.py +440 -0
- flywheel/models/viewer_app.py +381 -0
- flywheel/models/viewer_app_input.py +382 -0
- flywheel/models/viewer_app_type.py +29 -0
- flywheel/models/virus_scan.py +166 -0
- flywheel/models/virus_scan_state.py +30 -0
- flywheel/models/work_in_progress_features.py +135 -0
- flywheel/models/zipfile_info.py +192 -0
- flywheel/models/zipfile_member_info.py +241 -0
- flywheel/partial_reader.py +50 -0
- flywheel/rest.py +352 -0
- flywheel/util.py +95 -0
- flywheel/view_builder.py +449 -0
- flywheel_sdk-21.2.0rc0.dist-info/METADATA +41 -0
- flywheel_sdk-21.2.0rc0.dist-info/RECORD +772 -0
- flywheel_sdk-21.2.0rc0.dist-info/WHEEL +4 -0
- flywheel_sdk-21.2.0rc0.dist-info/licenses/LICENSE.txt +18 -0
flywheel/gear_context.py
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"""Provides gear helper functions"""
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
import json
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
import warnings
|
|
8
|
+
|
|
9
|
+
from .client import Client
|
|
10
|
+
|
|
11
|
+
DEFAULT_GEAR_PATH = "/flywheel/v0"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class GearContext(object):
|
|
15
|
+
"""
|
|
16
|
+
This class is DEPRECATED. Please use the
|
|
17
|
+
`Flywheel Gear Toolkit <https://flywheel-io.gitlab.io/public/gear-toolkit/index.html>`_
|
|
18
|
+
instead.
|
|
19
|
+
|
|
20
|
+
Provides helper functions for gear development
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, gear_path=None):
|
|
24
|
+
warnings.warn(
|
|
25
|
+
"Please use the Flywheel Gear Toolkit instead: https://flywheel-io.gitlab.io/public/gear-toolkit/index.html",
|
|
26
|
+
DeprecationWarning,
|
|
27
|
+
)
|
|
28
|
+
self._path = os.path.abspath(gear_path or DEFAULT_GEAR_PATH)
|
|
29
|
+
self._client = None
|
|
30
|
+
self._invocation = None
|
|
31
|
+
self._out_dir = None
|
|
32
|
+
self._work_dir = None
|
|
33
|
+
self._metadata = {}
|
|
34
|
+
self.log = logging.getLogger(__name__)
|
|
35
|
+
|
|
36
|
+
def init_logging(self, level="INFO"):
|
|
37
|
+
"""Initializes logging to the given level"""
|
|
38
|
+
logging.basicConfig(level=getattr(logging, level.upper(), None) or logging.INFO)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def config(self):
|
|
42
|
+
"""Get the config dictionary.
|
|
43
|
+
|
|
44
|
+
:return: The configuration dictionary.
|
|
45
|
+
:rtype: dict
|
|
46
|
+
"""
|
|
47
|
+
return self._get_invocation()["config"]
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def destination(self):
|
|
51
|
+
"""Get the destination reference.
|
|
52
|
+
|
|
53
|
+
:return: The destination dictionary.
|
|
54
|
+
:rtype: dict
|
|
55
|
+
"""
|
|
56
|
+
return self._get_invocation()["destination"]
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def work_dir(self):
|
|
60
|
+
"""Get the absolute path to a work directory
|
|
61
|
+
|
|
62
|
+
:return: The absolute path to work.
|
|
63
|
+
:rtype: str
|
|
64
|
+
"""
|
|
65
|
+
if self._work_dir is None:
|
|
66
|
+
self._work_dir = os.path.join(self._path, "work")
|
|
67
|
+
if not os.path.exists(self._work_dir):
|
|
68
|
+
os.makedirs(self._work_dir)
|
|
69
|
+
return self._work_dir
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def output_dir(self):
|
|
73
|
+
"""Get the absolute path to the output directory.
|
|
74
|
+
|
|
75
|
+
:return: The absolute path to outputs.
|
|
76
|
+
:rtype: str
|
|
77
|
+
"""
|
|
78
|
+
if self._out_dir is None:
|
|
79
|
+
self._out_dir = os.path.join(self._path, "output")
|
|
80
|
+
if not os.path.exists(self._out_dir):
|
|
81
|
+
os.makedirs(self._out_dir)
|
|
82
|
+
return self._out_dir
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def client(self):
|
|
86
|
+
"""Get the SDK client, if an api key input exists.
|
|
87
|
+
|
|
88
|
+
Raises a ValueError if there is no api-key input.
|
|
89
|
+
|
|
90
|
+
:return: The SDK client
|
|
91
|
+
:rtype: Client
|
|
92
|
+
"""
|
|
93
|
+
if self._client is None:
|
|
94
|
+
api_key = None
|
|
95
|
+
for inp in self._get_invocation()["inputs"].values():
|
|
96
|
+
if inp["base"] == "api-key" and inp["key"]:
|
|
97
|
+
api_key = inp["key"]
|
|
98
|
+
break
|
|
99
|
+
|
|
100
|
+
if api_key is None:
|
|
101
|
+
raise RuntimeError("Could not find an api-key in config")
|
|
102
|
+
|
|
103
|
+
self._client = Client(api_key)
|
|
104
|
+
return self._client
|
|
105
|
+
|
|
106
|
+
def log_config(self):
|
|
107
|
+
"""Print the configuration and input files to the logger"""
|
|
108
|
+
# Log destination
|
|
109
|
+
self.log.info(
|
|
110
|
+
"Destination is %s=%s",
|
|
111
|
+
self.destination.get("type"),
|
|
112
|
+
self.destination.get("id"),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Log file inputs
|
|
116
|
+
for inp_name, inp in self._get_invocation()["inputs"].items():
|
|
117
|
+
if inp["base"] != "file":
|
|
118
|
+
continue
|
|
119
|
+
|
|
120
|
+
container_type = inp.get("hierarchy", {}).get("type")
|
|
121
|
+
container_id = inp.get("hierarchy", {}).get("id")
|
|
122
|
+
file_name = inp.get("location", {}).get("name")
|
|
123
|
+
|
|
124
|
+
self.log.info(
|
|
125
|
+
'Input file "%s" is %s from %s=%s',
|
|
126
|
+
inp_name,
|
|
127
|
+
file_name,
|
|
128
|
+
container_type,
|
|
129
|
+
container_id,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Log configuration values
|
|
133
|
+
for key, value in self.config.items():
|
|
134
|
+
self.log.info('Config "%s=%s"', key, value)
|
|
135
|
+
|
|
136
|
+
def get_input(self, name):
|
|
137
|
+
"""Get the input for name.
|
|
138
|
+
|
|
139
|
+
:param str name: The name of the input
|
|
140
|
+
:return: The input dictionary, or None if not found.
|
|
141
|
+
:rtype: dict
|
|
142
|
+
"""
|
|
143
|
+
return self._get_invocation()["inputs"].get(name)
|
|
144
|
+
|
|
145
|
+
def get_input_path(self, name):
|
|
146
|
+
"""Get the full path to the given input file.
|
|
147
|
+
|
|
148
|
+
Raises an exception if the input exists, but is not a file.
|
|
149
|
+
|
|
150
|
+
:param str name: The name of the input
|
|
151
|
+
:return: The path to the input file if it exists, otherwise None
|
|
152
|
+
:rtype: str
|
|
153
|
+
"""
|
|
154
|
+
inp = self.get_input(name)
|
|
155
|
+
if inp is None:
|
|
156
|
+
return None
|
|
157
|
+
if inp["base"] != "file":
|
|
158
|
+
raise ValueError("The specified input {} is not a file".format(name))
|
|
159
|
+
return inp["location"]["path"]
|
|
160
|
+
|
|
161
|
+
def open_input(self, name, mode="r", **kwargs):
|
|
162
|
+
"""Open the named input file.
|
|
163
|
+
|
|
164
|
+
Raises an exception if the input does not exist or is not a file.
|
|
165
|
+
|
|
166
|
+
:param str name: The name of the input
|
|
167
|
+
:param str mode: The open mode (default is 'r')
|
|
168
|
+
:param ``**kwargs``: Additional args to pass to ``open``
|
|
169
|
+
:return: The file object
|
|
170
|
+
:rtype: file
|
|
171
|
+
"""
|
|
172
|
+
path = self.get_input_path(name)
|
|
173
|
+
if path is None:
|
|
174
|
+
raise OSError("An input named {} does not exist!".format(name))
|
|
175
|
+
|
|
176
|
+
return open(path, mode, **kwargs)
|
|
177
|
+
|
|
178
|
+
def open_output(self, name, mode="w", **kwargs):
|
|
179
|
+
"""Open the named output file.
|
|
180
|
+
|
|
181
|
+
:param str name: The name of the output
|
|
182
|
+
:param str mode: The open mode (default is 'w')
|
|
183
|
+
:param ``**kwargs``: Additional args to pass to ``open``
|
|
184
|
+
:return: The file object
|
|
185
|
+
:rtype: file
|
|
186
|
+
"""
|
|
187
|
+
path = os.path.join(self.output_dir, name)
|
|
188
|
+
return open(path, mode, **kwargs)
|
|
189
|
+
|
|
190
|
+
def get_context_value(self, name):
|
|
191
|
+
"""Get the context input for name.
|
|
192
|
+
|
|
193
|
+
:param str name: The name of the input
|
|
194
|
+
:return: The input context value, or None if not found.
|
|
195
|
+
:rtype: dict
|
|
196
|
+
"""
|
|
197
|
+
inp = self.get_input(name)
|
|
198
|
+
if not inp:
|
|
199
|
+
return None
|
|
200
|
+
if inp["base"] != "context":
|
|
201
|
+
raise ValueError("The specified input {} is not a context input".format(name))
|
|
202
|
+
return inp.get("value")
|
|
203
|
+
|
|
204
|
+
def update_container_metadata(self, container_type, *args, **kwargs):
|
|
205
|
+
"""Update metadata for the given container name in the hierarchy.
|
|
206
|
+
|
|
207
|
+
A dictionary and/or a set of key=value args can be passed to this function.
|
|
208
|
+
|
|
209
|
+
The metadata will be written when write_metadata() is called, or
|
|
210
|
+
if using this as a context manager, when the context is exited.
|
|
211
|
+
|
|
212
|
+
:param str container_type: The container type (e.g. session or acquisition)
|
|
213
|
+
:param ``*args``: The optional update dictionary
|
|
214
|
+
:param ``**kwargs``: The optional update key-value pairs
|
|
215
|
+
"""
|
|
216
|
+
update = self._create_update_dict(args, kwargs)
|
|
217
|
+
self._update_metadata(container_type, update)
|
|
218
|
+
|
|
219
|
+
def update_file_metadata(self, file_name, *args, **kwargs):
|
|
220
|
+
"""Update metadata for the given file on the destination.
|
|
221
|
+
|
|
222
|
+
A dictionary and/or a set of key=value args can be passed to this function.
|
|
223
|
+
|
|
224
|
+
The metadata will be written when write_metadata() is called, or
|
|
225
|
+
if using this as a context manager, when the context is exited.
|
|
226
|
+
|
|
227
|
+
:param str file_name: The name of the file
|
|
228
|
+
:param ``*args``: The optional update dictionary
|
|
229
|
+
:param ``**kwargs``: The optional update key-value pairs
|
|
230
|
+
"""
|
|
231
|
+
container_type = self.destination["type"]
|
|
232
|
+
update = self._create_update_dict(args, kwargs)
|
|
233
|
+
self._update_metadata(container_type, update, file_name=file_name)
|
|
234
|
+
|
|
235
|
+
def update_destination_metadata(self, *args, **kwargs):
|
|
236
|
+
"""Update metadata for the destination container.
|
|
237
|
+
|
|
238
|
+
A dictionary and/or a set of key=value args can be passed to this function.
|
|
239
|
+
|
|
240
|
+
The metadata will be written when write_metadata() is called, or
|
|
241
|
+
if using this as a context manager, when the context is exited.
|
|
242
|
+
|
|
243
|
+
:param ``*args``: The optional update dictionary
|
|
244
|
+
:param ``**kwargs``: The optional update key-value pairs
|
|
245
|
+
"""
|
|
246
|
+
container_type = self.destination["type"]
|
|
247
|
+
update = self._create_update_dict(args, kwargs)
|
|
248
|
+
self._update_metadata(container_type, update)
|
|
249
|
+
|
|
250
|
+
def write_metadata(self):
|
|
251
|
+
"""Write the metadata json file to the output folder"""
|
|
252
|
+
if not self._metadata:
|
|
253
|
+
return
|
|
254
|
+
|
|
255
|
+
with self.open_output(".metadata.json") as f:
|
|
256
|
+
json.dump(self._metadata, f, indent=2)
|
|
257
|
+
|
|
258
|
+
def download_session_bids(self, target_dir="work/bids", src_data=False, folders=None, **kwargs):
|
|
259
|
+
"""Download the session in bids format to target_dir.
|
|
260
|
+
|
|
261
|
+
:param str target_dir: The destination directory (otherwise work/bids will be used)
|
|
262
|
+
:param bool src_data: Whether or not to include src data (e.g. dicoms)
|
|
263
|
+
:param list folders: The list of folders to include (otherwise all folders) e.g. ['anat', 'func']
|
|
264
|
+
:param ``**kwargs``: Additional arguments to pass to ``download_bids_dir``
|
|
265
|
+
:return: The absolute path to the downloaded bids directory
|
|
266
|
+
:rtype: str
|
|
267
|
+
"""
|
|
268
|
+
kwargs["src_data"] = src_data
|
|
269
|
+
kwargs["folders"] = folders
|
|
270
|
+
return self._download_bids("session", target_dir, kwargs)
|
|
271
|
+
|
|
272
|
+
def download_project_bids(
|
|
273
|
+
self, target_dir="work/bids", src_data=False, subjects=None, sessions=None, folders=None, **kwargs
|
|
274
|
+
):
|
|
275
|
+
"""Download the project in bids format to target_dir.
|
|
276
|
+
|
|
277
|
+
:param str target_dir: The destination directory (otherwise work/bids will be used)
|
|
278
|
+
:param bool src_data: Whether or not to include src data (e.g. dicoms)
|
|
279
|
+
:param list subjects: The list of subjects to include (via subject code) otherwise all subjects
|
|
280
|
+
:param list sessions: The list of sessions to include (via session label) otherwise all sessions
|
|
281
|
+
:param list folders: The list of folders to include (otherwise all folders) e.g. ['anat', 'func']
|
|
282
|
+
:param ``**kwargs``: Additional arguments to pass to ``download_bids_dir``
|
|
283
|
+
:return: The absolute path to the downloaded bids directory
|
|
284
|
+
:rtype: str
|
|
285
|
+
"""
|
|
286
|
+
kwargs["src_data"] = src_data
|
|
287
|
+
kwargs["subjects"] = subjects
|
|
288
|
+
kwargs["sessions"] = sessions
|
|
289
|
+
kwargs["folders"] = folders
|
|
290
|
+
return self._download_bids("project", target_dir, kwargs)
|
|
291
|
+
|
|
292
|
+
def __enter__(self):
|
|
293
|
+
return self
|
|
294
|
+
|
|
295
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
296
|
+
if exc_type is None:
|
|
297
|
+
self.write_metadata()
|
|
298
|
+
|
|
299
|
+
def _download_bids(self, container_type, target_dir, kwargs):
|
|
300
|
+
"""Download bids to the given target directory"""
|
|
301
|
+
# Raise a specific error if BIDS not installed
|
|
302
|
+
download_bids_dir = self._load_download_bids()
|
|
303
|
+
|
|
304
|
+
# Cleanup kwargs
|
|
305
|
+
for key in ("subjects", "sessions", "folders"):
|
|
306
|
+
if key in kwargs and kwargs[key] is None:
|
|
307
|
+
kwargs.pop(key)
|
|
308
|
+
|
|
309
|
+
# Resolve container type from parents
|
|
310
|
+
dest_container = self.client.get(self.destination["id"])
|
|
311
|
+
|
|
312
|
+
parent_id = dest_container.get(container_type)
|
|
313
|
+
if parent_id is None:
|
|
314
|
+
parent_id = dest_container.get("parents", {}).get(container_type)
|
|
315
|
+
|
|
316
|
+
if parent_id is None:
|
|
317
|
+
raise RuntimeError("Cannot find {} from destination".format(container_type))
|
|
318
|
+
|
|
319
|
+
self.log.info("Using source container: %s=%s", container_type, parent_id)
|
|
320
|
+
|
|
321
|
+
# Download bids to the target directory
|
|
322
|
+
# download_bids_dir will create the target path
|
|
323
|
+
target_path = os.path.join(self._path, target_dir)
|
|
324
|
+
download_bids_dir(self.client, parent_id, container_type, target_path, **kwargs)
|
|
325
|
+
return target_path
|
|
326
|
+
|
|
327
|
+
def _load_download_bids(self):
|
|
328
|
+
"""Load the download_bids_dir function from flywheel_bids"""
|
|
329
|
+
try:
|
|
330
|
+
from flywheel_bids.export_bids import download_bids_dir
|
|
331
|
+
|
|
332
|
+
return download_bids_dir
|
|
333
|
+
except ImportError:
|
|
334
|
+
self.log.error("Cannot load flywheel-bids package.")
|
|
335
|
+
self.log.error('Make sure it is installed with "pip install flywheel-bids"')
|
|
336
|
+
raise RuntimeError("Unable to load flywheel-bids package, make sure it is installed!")
|
|
337
|
+
|
|
338
|
+
def _get_invocation(self):
|
|
339
|
+
"""Load the invocation"""
|
|
340
|
+
if self._invocation is None:
|
|
341
|
+
cfg_path = os.path.join(self._path, "config.json")
|
|
342
|
+
try:
|
|
343
|
+
with open(cfg_path, "r") as f:
|
|
344
|
+
self._invocation = json.load(f)
|
|
345
|
+
except Exception:
|
|
346
|
+
self.log.exception("Cannot load config.json at <%s>", cfg_path)
|
|
347
|
+
raise
|
|
348
|
+
|
|
349
|
+
return self._invocation
|
|
350
|
+
|
|
351
|
+
def _update_metadata(self, container_type, metadata, file_name=None):
|
|
352
|
+
dest = self._metadata.setdefault(container_type, {})
|
|
353
|
+
if file_name:
|
|
354
|
+
files = dest.setdefault("files", [])
|
|
355
|
+
file_entry = None
|
|
356
|
+
for fe in files:
|
|
357
|
+
if fe.get("name") == file_name:
|
|
358
|
+
file_entry = fe
|
|
359
|
+
break
|
|
360
|
+
if file_entry is None:
|
|
361
|
+
file_entry = {"name": file_name}
|
|
362
|
+
files.append(file_entry)
|
|
363
|
+
dest = file_entry
|
|
364
|
+
|
|
365
|
+
dest.update(metadata)
|
|
366
|
+
|
|
367
|
+
@staticmethod
|
|
368
|
+
def _create_update_dict(args, kwargs):
|
|
369
|
+
result = copy.deepcopy(kwargs) or {}
|
|
370
|
+
if len(args) > 0:
|
|
371
|
+
if len(args) > 1 or not isinstance(args[0], dict):
|
|
372
|
+
raise ValueError("Expected at most one update dictionary")
|
|
373
|
+
result.update(args[0])
|
|
374
|
+
return result
|