synapseclient 4.3.0__tar.gz → 4.4.0__tar.gz

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.
Files changed (110) hide show
  1. {synapseclient-4.3.0/synapseclient.egg-info → synapseclient-4.4.0}/PKG-INFO +1 -2
  2. {synapseclient-4.3.0 → synapseclient-4.4.0}/pyproject.toml +3 -0
  3. {synapseclient-4.3.0 → synapseclient-4.4.0}/setup.cfg +0 -1
  4. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/__init__.py +17 -18
  5. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/__main__.py +18 -16
  6. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/activity.py +1 -1
  7. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/annotations.py +6 -5
  8. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/api/__init__.py +30 -5
  9. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/api/annotations.py +36 -3
  10. synapseclient-4.4.0/synapseclient/api/configuration_services.py +138 -0
  11. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/api/entity_bundle_services_v2.py +5 -1
  12. synapseclient-4.4.0/synapseclient/api/entity_factory.py +391 -0
  13. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/api/entity_services.py +71 -7
  14. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/api/file_services.py +136 -4
  15. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/client.py +217 -163
  16. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/async_utils.py +1 -1
  17. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/cache.py +5 -3
  18. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/constants/method_flags.py +2 -0
  19. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/credentials/cred_data.py +2 -1
  20. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/credentials/credential_provider.py +6 -5
  21. synapseclient-4.4.0/synapseclient/core/download/__init__.py +35 -0
  22. synapseclient-4.4.0/synapseclient/core/download/download_async.py +548 -0
  23. synapseclient-4.4.0/synapseclient/core/download/download_functions.py +982 -0
  24. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/exceptions.py +22 -5
  25. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/logging_setup.py +0 -1
  26. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/models/permission.py +1 -1
  27. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/multithread_download/download_threads.py +66 -0
  28. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/remote_file_storage_wrappers.py +38 -28
  29. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/retry.py +21 -5
  30. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/sts_transfer.py +2 -1
  31. synapseclient-4.4.0/synapseclient/core/transfer_bar.py +151 -0
  32. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/upload/multipart_upload.py +2 -4
  33. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/upload/multipart_upload_async.py +4 -15
  34. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/upload/upload_functions.py +20 -19
  35. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/upload/upload_functions_async.py +22 -43
  36. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/utils.py +2 -34
  37. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/entity.py +4 -2
  38. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/evaluation.py +2 -3
  39. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/__init__.py +7 -13
  40. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/activity.py +37 -2
  41. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/annotations.py +7 -16
  42. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/file.py +107 -48
  43. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/folder.py +8 -14
  44. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/mixins/access_control.py +3 -1
  45. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/mixins/storable_container.py +233 -9
  46. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/project.py +8 -13
  47. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/access_control_protocol.py +3 -1
  48. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/activity_protocol.py +4 -0
  49. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/annotations_protocol.py +1 -0
  50. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/file_protocol.py +9 -2
  51. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/folder_protocol.py +4 -1
  52. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/project_protocol.py +4 -1
  53. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/storable_container_protocol.py +1 -0
  54. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/table_protocol.py +7 -6
  55. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/team_protocol.py +12 -7
  56. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/user_protocol.py +4 -2
  57. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/services/search.py +6 -14
  58. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/services/storable_entity.py +2 -1
  59. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/services/storable_entity_components.py +9 -3
  60. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/table.py +9 -7
  61. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/team.py +8 -7
  62. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/user.py +4 -2
  63. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/services/json_schema.py +4 -5
  64. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/synapsePythonClient +1 -1
  65. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/table.py +19 -17
  66. {synapseclient-4.3.0 → synapseclient-4.4.0/synapseclient.egg-info}/PKG-INFO +1 -2
  67. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient.egg-info/SOURCES.txt +8 -1
  68. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient.egg-info/requires.txt +0 -1
  69. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/__init__.py +5 -5
  70. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/copy_functions.py +12 -11
  71. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/migrate_functions.py +3 -4
  72. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/sync.py +316 -354
  73. synapseclient-4.4.0/tests/test_utils.py +23 -0
  74. {synapseclient-4.3.0 → synapseclient-4.4.0}/MANIFEST.in +0 -0
  75. {synapseclient-4.3.0 → synapseclient-4.4.0}/README.md +0 -0
  76. {synapseclient-4.3.0 → synapseclient-4.4.0}/setup.py +2 -2
  77. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/.synapseConfig +0 -0
  78. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/__init__.py +0 -0
  79. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/config.py +0 -0
  80. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/constants/__init__.py +0 -0
  81. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/constants/concrete_types.py +0 -0
  82. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/constants/config_file_constants.py +0 -0
  83. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/constants/limits.py +0 -0
  84. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/credentials/__init__.py +1 -1
  85. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/cumulative_transfer_progress.py +2 -2
  86. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/dozer.py +0 -0
  87. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/lock.py +2 -2
  88. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/models/__init__.py +0 -0
  89. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/models/custom_json.py +1 -1
  90. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/models/dict_object.py +0 -0
  91. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/multithread_download/__init__.py +1 -1
  92. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/pool_provider.py +1 -1
  93. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/upload/__init__.py +1 -1
  94. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/upload/upload_utils.py +0 -0
  95. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/core/version_check.py +2 -2
  96. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/evaluation.py +0 -0
  97. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/mixins/__init__.py +0 -0
  98. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/protocols/__init__.py +0 -0
  99. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/services/__init__.py +3 -3
  100. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/models/wiki.py +0 -0
  101. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/services/__init__.py +0 -0
  102. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/team.py +0 -0
  103. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient/wiki.py +1 -1
  104. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient.egg-info/dependency_links.txt +0 -0
  105. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient.egg-info/entry_points.txt +0 -0
  106. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient.egg-info/not-zip-safe +0 -0
  107. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseclient.egg-info/top_level.txt +0 -0
  108. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/describe_functions.py +1 -1
  109. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/monitor.py +0 -0
  110. {synapseclient-4.3.0 → synapseclient-4.4.0}/synapseutils/walk_functions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: synapseclient
3
- Version: 4.3.0
3
+ Version: 4.4.0
4
4
  Summary: A client for Synapse, a collaborative, open-source research platform that allows teams to share data, track analyses, and collaborate.
5
5
  Home-page: https://www.synapse.org
6
6
  Author: The Synapse Engineering Team
@@ -39,7 +39,6 @@ Requires-Dist: nest-asyncio~=1.6.0
39
39
  Requires-Dist: asyncio-atexit~=1.0.1
40
40
  Requires-Dist: httpx~=0.27.0
41
41
  Requires-Dist: tqdm<5.0,>=4.66.2
42
- Requires-Dist: loky~=3.0.0
43
42
  Requires-Dist: async-lru~=2.0.4
44
43
  Requires-Dist: psutil~=5.9.8
45
44
  Provides-Extra: dev
@@ -13,3 +13,6 @@ exclude = [
13
13
  [tool.bandit]
14
14
  exclude_dirs = ["tests"]
15
15
  skips = ["B101", "B303", "B608", "B311", "B113", "B310", "B110"]
16
+
17
+ [tool.isort]
18
+ profile = "black"
@@ -48,7 +48,6 @@ install_requires =
48
48
  asyncio-atexit~=1.0.1
49
49
  httpx~=0.27.0
50
50
  tqdm>=4.66.2,<5.0
51
- loky~=3.0.0
52
51
  async-lru~=2.0.4
53
52
  psutil~=5.9.8
54
53
  tests_require =
@@ -1,36 +1,35 @@
1
1
  import importlib.resources
2
-
3
2
  import json
3
+
4
4
  import requests # ensure user-agent is set to track Synapse Python client usage
5
5
 
6
6
  from .activity import Activity
7
7
  from .annotations import Annotations
8
- from .client import PUBLIC, AUTHENTICATED_USERS
9
8
 
10
9
  # public APIs
11
- from .client import Synapse, login
10
+ from .client import AUTHENTICATED_USERS, PUBLIC, Synapse, login
11
+ from .core.models.permission import Permissions
12
12
  from .core.version_check import check_for_updates, release_notes
13
- from .entity import Entity, Project, Folder, File, Link, DockerRepository
13
+ from .entity import DockerRepository, Entity, File, Folder, Link, Project
14
14
  from .evaluation import Evaluation, Submission, SubmissionStatus
15
15
  from .table import (
16
- Schema,
17
- EntityViewSchema,
18
16
  Column,
19
- RowSet,
17
+ Dataset,
18
+ EntityViewSchema,
19
+ EntityViewType,
20
+ MaterializedViewSchema,
21
+ PartialRowset,
20
22
  Row,
21
- as_table_columns,
23
+ RowSet,
24
+ Schema,
25
+ SubmissionViewSchema,
22
26
  Table,
23
- PartialRowset,
24
- EntityViewType,
27
+ as_table_columns,
25
28
  build_table,
26
- SubmissionViewSchema,
27
- MaterializedViewSchema,
28
- Dataset,
29
29
  delete_rows,
30
30
  )
31
- from .team import Team, UserProfile, UserGroupHeader, TeamMember
31
+ from .team import Team, TeamMember, UserGroupHeader, UserProfile
32
32
  from .wiki import Wiki
33
- from .core.models.permission import Permissions
34
33
 
35
34
  # ref = importlib.resources.files(__name__).joinpath("synapsePythonClient")
36
35
  # with ref.open("r") as fp:
@@ -93,8 +92,8 @@ USER_AGENT_COMMAND_LINE = {
93
92
  % (__version__, requests.utils.default_user_agent())
94
93
  }
95
94
 
96
- # patch json
97
- from .core.models import custom_json # noqa
98
-
99
95
  # patch logging
100
96
  from .core import logging_setup # noqa
97
+
98
+ # patch json
99
+ from .core.models import custom_json # noqa
@@ -7,35 +7,35 @@ https://python-docs.synapse.org/build/html/CommandLineClient.html
7
7
 
8
8
  import argparse
9
9
  import collections.abc
10
+ import csv
11
+ import getpass
12
+ import json
10
13
  import logging
11
14
  import os
12
- import sys
13
- import signal
14
- import json
15
- import getpass
16
- import csv
17
15
  import re
18
16
  import shutil
17
+ import signal
18
+ import sys
19
+
20
+ from opentelemetry import trace
21
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
22
+ from opentelemetry.sdk.resources import SERVICE_NAME, Resource
23
+ from opentelemetry.sdk.trace import TracerProvider
24
+ from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
25
+ from opentelemetry.sdk.trace.sampling import ALWAYS_OFF, ALWAYS_ON, ParentBased
19
26
 
20
27
  import synapseclient
21
28
  import synapseutils
22
-
23
29
  from synapseclient import Activity
24
- from synapseclient.wiki import Wiki
25
30
  from synapseclient.annotations import Annotations
26
31
  from synapseclient.core import utils
27
32
  from synapseclient.core.exceptions import (
28
33
  SynapseAuthenticationError,
29
- SynapseHTTPError,
30
34
  SynapseFileNotFoundError,
35
+ SynapseHTTPError,
31
36
  SynapseNoCredentialsError,
32
37
  )
33
- from opentelemetry import trace
34
- from opentelemetry.sdk.trace import TracerProvider
35
- from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
36
- from opentelemetry.sdk.resources import SERVICE_NAME, Resource
37
- from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
38
- from opentelemetry.sdk.trace.sampling import ALWAYS_OFF, ALWAYS_ON, ParentBased
38
+ from synapseclient.wiki import Wiki
39
39
 
40
40
  tracer = trace.get_tracer("synapseclient")
41
41
 
@@ -109,6 +109,7 @@ def _getIdsFromQuery(queryString, syn, downloadLocation):
109
109
  @tracer.start_as_current_span("main::get")
110
110
  def get(args, syn):
111
111
  syn.multi_threaded = args.multiThreaded
112
+ printed_download_message = False
112
113
  if args.recursive:
113
114
  if args.version is not None:
114
115
  raise ValueError(
@@ -161,13 +162,14 @@ def get(args, syn):
161
162
  and entity.path is not None
162
163
  and os.path.exists(entity.path)
163
164
  ):
164
- syn.logger.info("Downloaded file: %s", os.path.basename(entity.path))
165
+ # The core download functionality of syn.get will print out the message
166
+ printed_download_message = True
165
167
  else:
166
168
  syn.logger.info(
167
169
  "WARNING: No files associated with entity %s\n", entity.id
168
170
  )
169
171
  syn.logger.info(entity)
170
- if "path" in entity:
172
+ if "path" in entity and not printed_download_message:
171
173
  syn.logger.info("Creating %s", entity.path)
172
174
 
173
175
 
@@ -55,7 +55,7 @@ For example, when storing a data entity, it's a good idea to record its source:
55
55
  import collections.abc
56
56
 
57
57
  from synapseclient.core.exceptions import SynapseError, SynapseMalformedEntityError
58
- from synapseclient.core.utils import is_url, is_synapse_id_str, get_synid_and_version
58
+ from synapseclient.core.utils import get_synid_and_version, is_synapse_id_str, is_url
59
59
  from synapseclient.entity import is_synapse_entity
60
60
 
61
61
 
@@ -71,17 +71,18 @@ See also:
71
71
  """
72
72
 
73
73
  import collections
74
+ import datetime
75
+ import typing
74
76
 
75
- from .entity import Entity
76
77
  from synapseclient.core.utils import (
77
- to_unix_epoch_time,
78
78
  from_unix_epoch_time,
79
+ id_of,
79
80
  is_date,
80
81
  to_list,
81
- id_of,
82
+ to_unix_epoch_time,
82
83
  )
83
- import typing
84
- import datetime
84
+
85
+ from .entity import Entity
85
86
 
86
87
 
87
88
  def _identity(x):
@@ -1,35 +1,48 @@
1
1
  # These are all of the models that are used by the Synapse client.
2
- from .annotations import set_annotations
2
+ from .annotations import set_annotations, set_annotations_async
3
+ from .configuration_services import (
4
+ get_client_authenticated_s3_profile,
5
+ get_config_authentication,
6
+ get_config_file,
7
+ get_config_section_dict,
8
+ get_transfer_config,
9
+ )
3
10
  from .entity_bundle_services_v2 import (
4
11
  get_entity_id_bundle2,
5
12
  get_entity_id_version_bundle2,
6
13
  post_entity_bundle2_create,
7
14
  put_entity_id_bundle2,
8
15
  )
16
+ from .entity_factory import get_from_entity_factory
9
17
  from .entity_services import (
18
+ create_access_requirements_if_none,
19
+ delete_entity_generated_by,
20
+ get_entities_by_md5,
10
21
  get_entity,
22
+ get_entity_path,
11
23
  get_upload_destination,
12
24
  get_upload_destination_location,
13
25
  post_entity,
14
26
  put_entity,
15
- create_access_requirements_if_none,
16
- delete_entity_generated_by,
17
27
  )
18
28
  from .file_services import (
29
+ AddPartResponse,
19
30
  get_file_handle,
31
+ get_file_handle_for_download,
32
+ get_file_handle_for_download_async,
20
33
  post_external_filehandle,
21
34
  post_external_object_store_filehandle,
22
35
  post_external_s3_file_handle,
23
36
  post_file_multipart,
24
- put_file_multipart_complete,
25
37
  post_file_multipart_presigned_urls,
26
38
  put_file_multipart_add,
27
- AddPartResponse,
39
+ put_file_multipart_complete,
28
40
  )
29
41
 
30
42
  __all__ = [
31
43
  # annotations
32
44
  "set_annotations",
45
+ "set_annotations_async",
33
46
  "get_entity_id_bundle2",
34
47
  "get_entity_id_version_bundle2",
35
48
  "post_entity_bundle2_create",
@@ -45,6 +58,8 @@ __all__ = [
45
58
  "post_file_multipart_presigned_urls",
46
59
  "put_file_multipart_add",
47
60
  "AddPartResponse",
61
+ "get_file_handle_for_download_async",
62
+ "get_file_handle_for_download",
48
63
  # entity_services
49
64
  "get_entity",
50
65
  "put_entity",
@@ -53,4 +68,14 @@ __all__ = [
53
68
  "get_upload_destination_location",
54
69
  "create_access_requirements_if_none",
55
70
  "delete_entity_generated_by",
71
+ "get_entity_path",
72
+ "get_entities_by_md5",
73
+ # configuration_services
74
+ "get_config_file",
75
+ "get_config_section_dict",
76
+ "get_config_authentication",
77
+ "get_client_authenticated_s3_profile",
78
+ "get_transfer_config",
79
+ # entity_factory
80
+ "get_from_entity_factory",
56
81
  ]
@@ -4,20 +4,19 @@ annotations that are not cleanly provided by the synapseclient library.
4
4
  """
5
5
 
6
6
  import json
7
-
8
7
  from dataclasses import asdict
9
-
10
8
  from typing import TYPE_CHECKING, Optional
11
9
 
12
10
  from synapseclient.annotations import _convert_to_annotations_list
13
11
 
14
12
  if TYPE_CHECKING:
15
- from synapseclient.models import Annotations
16
13
  from synapseclient import Synapse
14
+ from synapseclient.models import Annotations
17
15
 
18
16
 
19
17
  def set_annotations(
20
18
  annotations: "Annotations",
19
+ *,
21
20
  synapse_client: Optional["Synapse"] = None,
22
21
  ):
23
22
  """Call to synapse and set the annotations for the given input.
@@ -47,3 +46,37 @@ def set_annotations(
47
46
  }
48
47
  ),
49
48
  )
49
+
50
+
51
+ async def set_annotations_async(
52
+ annotations: "Annotations",
53
+ *,
54
+ synapse_client: Optional["Synapse"] = None,
55
+ ):
56
+ """Call to synapse and set the annotations for the given input.
57
+
58
+ Arguments:
59
+ annotations: The annotations to set. This is expected to have the id, etag,
60
+ and annotations filled in.
61
+ synapse_client: If not passed in or None this will use the last client from
62
+ the `.login()` method.
63
+
64
+ Returns: The annotations set in Synapse.
65
+ """
66
+ annotations_dict = asdict(annotations)
67
+
68
+ synapse_annotations = _convert_to_annotations_list(
69
+ annotations_dict["annotations"] or {}
70
+ )
71
+ from synapseclient import Synapse
72
+
73
+ return await Synapse.get_client(synapse_client=synapse_client).rest_put_async(
74
+ f"/entity/{annotations.id}/annotations2",
75
+ body=json.dumps(
76
+ {
77
+ "id": annotations.id,
78
+ "etag": annotations.etag,
79
+ "annotations": synapse_annotations,
80
+ }
81
+ ),
82
+ )
@@ -0,0 +1,138 @@
1
+ """This module is responsible for exposing access to any configuration either through
2
+ file, environment variables, or other means.
3
+ """
4
+
5
+ import configparser
6
+ import functools
7
+ import urllib.parse
8
+ from typing import Dict
9
+
10
+ from synapseclient.core.constants import config_file_constants
11
+ from synapseclient.core.pool_provider import DEFAULT_NUM_THREADS
12
+
13
+
14
+ @functools.lru_cache()
15
+ def get_config_file(config_path: str) -> configparser.RawConfigParser:
16
+ """
17
+ Retrieves the client configuration information.
18
+
19
+ Arguments:
20
+ config_path: Path to configuration file on local file system
21
+
22
+ Returns:
23
+ A RawConfigParser populated with properties from the user's configuration file.
24
+ """
25
+
26
+ try:
27
+ config = configparser.RawConfigParser()
28
+ config.read(config_path) # Does not fail if the file does not exist
29
+ return config
30
+ except configparser.Error as ex:
31
+ raise ValueError(f"Error parsing Synapse config file: {config_path}") from ex
32
+
33
+
34
+ def get_config_section_dict(
35
+ section_name: str,
36
+ config_path: str,
37
+ ) -> Dict[str, str]:
38
+ """
39
+ Get a profile section in the configuration file with the section name.
40
+
41
+ Arguments:
42
+ section_name: The name of the profile section in the configuration file
43
+ config_path: Path to configuration file on local file system
44
+
45
+ Returns:
46
+ A dictionary containing the configuration profile section content. If the
47
+ section does not exist, an empty dictionary is returned.
48
+ """
49
+ config = get_config_file(config_path)
50
+ try:
51
+ return dict(config.items(section_name))
52
+ except configparser.NoSectionError:
53
+ # section not present
54
+ return {}
55
+
56
+
57
+ def get_client_authenticated_s3_profile(
58
+ endpoint: str,
59
+ bucket: str,
60
+ config_path: str,
61
+ ) -> Dict[str, str]:
62
+ """
63
+ Get the authenticated S3 profile from the configuration file.
64
+
65
+ Arguments:
66
+ endpoint: The location of the target service
67
+ bucket: AWS S3 bucket name
68
+ config_path: Path to configuration file on local file system
69
+
70
+ Returns:
71
+ The authenticated S3 profile
72
+ """
73
+
74
+ config_section = urllib.parse.urljoin(base=endpoint, url=bucket)
75
+ return get_config_section_dict(
76
+ section_name=config_section, config_path=config_path
77
+ ).get("profile_name", "default")
78
+
79
+
80
+ def get_config_authentication(
81
+ config_path: str,
82
+ ) -> Dict[str, str]:
83
+ """
84
+ Get the authentication section of the configuration file.
85
+
86
+ Arguments:
87
+ config_path: Path to configuration file on local file system
88
+
89
+ Returns:
90
+ The authentication section of the configuration file
91
+ """
92
+ return get_config_section_dict(
93
+ section_name=config_file_constants.AUTHENTICATION_SECTION_NAME,
94
+ config_path=config_path,
95
+ )
96
+
97
+
98
+ def get_transfer_config(
99
+ config_path: str,
100
+ ) -> Dict[str, str]:
101
+ """
102
+ Get the transfer profile from the configuration file.
103
+
104
+ Arguments:
105
+ config_path: Path to configuration file on local file system
106
+
107
+ Raises:
108
+ ValueError: Invalid max_threads value. Should be equal or less than 16.
109
+ ValueError: Invalid use_boto_sts value. Should be true or false.
110
+
111
+ Returns:
112
+ The transfer profile
113
+ """
114
+ # defaults
115
+ transfer_config = {"max_threads": DEFAULT_NUM_THREADS, "use_boto_sts": False}
116
+
117
+ for k, v in get_config_section_dict(
118
+ section_name="transfer", config_path=config_path
119
+ ).items():
120
+ if v:
121
+ if k == "max_threads":
122
+ try:
123
+ transfer_config["max_threads"] = int(v)
124
+ except ValueError as cause:
125
+ raise ValueError(
126
+ f"Invalid transfer.max_threads config setting {v}"
127
+ ) from cause
128
+
129
+ elif k == "use_boto_sts":
130
+ lower_v = v.lower()
131
+ if lower_v not in ("true", "false"):
132
+ raise ValueError(
133
+ f"Invalid transfer.use_boto_sts config setting {v}"
134
+ )
135
+
136
+ transfer_config["use_boto_sts"] = "true" == lower_v
137
+
138
+ return transfer_config
@@ -3,7 +3,7 @@
3
3
  """
4
4
 
5
5
  import json
6
- from typing import Any, Dict, Optional, TYPE_CHECKING
6
+ from typing import TYPE_CHECKING, Any, Dict, Optional
7
7
 
8
8
  if TYPE_CHECKING:
9
9
  from synapseclient import Synapse
@@ -12,6 +12,7 @@ if TYPE_CHECKING:
12
12
  async def get_entity_id_bundle2(
13
13
  entity_id: str,
14
14
  request: Optional[Dict[str, bool]] = None,
15
+ *,
15
16
  synapse_client: Optional["Synapse"] = None,
16
17
  ) -> Dict[str, Any]:
17
18
  """
@@ -53,6 +54,7 @@ async def get_entity_id_version_bundle2(
53
54
  entity_id: str,
54
55
  version: int,
55
56
  request: Optional[Dict[str, bool]] = None,
57
+ *,
56
58
  synapse_client: Optional["Synapse"] = None,
57
59
  ) -> Dict[str, Any]:
58
60
  """
@@ -93,6 +95,7 @@ async def get_entity_id_version_bundle2(
93
95
  async def post_entity_bundle2_create(
94
96
  request: Dict[str, Any],
95
97
  generated_by: Optional[str] = None,
98
+ *,
96
99
  synapse_client: Optional["Synapse"] = None,
97
100
  ) -> Dict[str, Any]:
98
101
  """
@@ -121,6 +124,7 @@ async def put_entity_id_bundle2(
121
124
  entity_id: str,
122
125
  request: Dict[str, Any],
123
126
  generated_by: Optional[str] = None,
127
+ *,
124
128
  synapse_client: Optional["Synapse"] = None,
125
129
  ) -> Dict[str, Any]:
126
130
  """