fair-cli 0.9.7__tar.gz → 0.9.8__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 (37) hide show
  1. {fair_cli-0.9.7 → fair_cli-0.9.8}/CITATION.cff +1 -1
  2. {fair_cli-0.9.7 → fair_cli-0.9.8}/PKG-INFO +1 -1
  3. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/cli.py +1 -1
  4. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/common.py +4 -0
  5. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/identifiers.py +7 -4
  6. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/logging.py +1 -1
  7. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/requests.py +2 -2
  8. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/sync.py +8 -7
  9. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/session.py +12 -15
  10. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/staging.py +5 -3
  11. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/user_config/__init__.py +3 -3
  12. {fair_cli-0.9.7 → fair_cli-0.9.8}/pyproject.toml +1 -1
  13. {fair_cli-0.9.7 → fair_cli-0.9.8}/CHANGELOG.md +0 -0
  14. {fair_cli-0.9.7 → fair_cli-0.9.8}/LICENSE +0 -0
  15. {fair_cli-0.9.7 → fair_cli-0.9.8}/README.md +0 -0
  16. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/__init__.py +0 -0
  17. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/configuration/__init__.py +0 -0
  18. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/configuration/validation.py +0 -0
  19. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/exceptions.py +0 -0
  20. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/files.txt +0 -0
  21. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/history.py +0 -0
  22. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/register.py +0 -0
  23. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/__init__.py +0 -0
  24. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/file_formats.json +0 -0
  25. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/file_types.py +0 -0
  26. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/server.py +0 -0
  27. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/storage.py +0 -0
  28. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/registry/versioning.py +0 -0
  29. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/run.py +0 -0
  30. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/templates/__init__.py +0 -0
  31. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/templates/config.jinja +0 -0
  32. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/templates/hist.jinja +0 -0
  33. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/testing.py +0 -0
  34. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/user_config/globbing.py +0 -0
  35. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/user_config/validation.py +0 -0
  36. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/utilities.py +0 -0
  37. {fair_cli-0.9.7 → fair_cli-0.9.8}/fair/virtualenv.py +0 -0
@@ -36,4 +36,4 @@ license: BSD-2-Clause
36
36
  message: If you use this software, please cite it using these metadata.
37
37
  repository-code: https://github.com/FAIRDataPipeline/FAIR-CLI/
38
38
  title: "The FAIR Data Pipeline command line tool"
39
- version: 0.9.7
39
+ version: 0.9.8
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fair-cli
3
- Version: 0.9.7
3
+ Version: 0.9.8
4
4
  Summary: Synchronization interface for the SCRC FAIR Data Pipeline registry
5
5
  License: BSD-2-Clause
6
6
  Keywords: FAIR Data Pipeline,FAIR,Data Management,Provenance
@@ -347,7 +347,7 @@ def purge(glob: bool, debug: bool, yes: bool, data: bool, all: bool) -> None:
347
347
  )
348
348
  else:
349
349
  _purge = click.confirm(
350
- "Are you sure you want to reset FAIR tracking, " "this is not reversible?"
350
+ "Are you sure you want to reset FAIR tracking, this is not reversible?"
351
351
  )
352
352
  if data:
353
353
  data = click.confirm(
@@ -308,7 +308,11 @@ def set_file_permissions(path: str):
308
308
 
309
309
  def remove_readonly(fn, path, excinfo):
310
310
  try:
311
+ _ = excinfo # Required to avoid unused variable warning
312
+ # Remove readonly bit
311
313
  os.chmod(path, stat.S_IWRITE)
314
+ # Call the provided function again
312
315
  fn(path)
313
316
  except Exception as exc:
317
+ # Log the error
314
318
  print("Skipped:", path, "because:\n", exc)
@@ -30,6 +30,9 @@ from fake_useragent import UserAgent
30
30
 
31
31
  logger = logging.getLogger("FAIRDataPipeline.Identifiers")
32
32
 
33
+ JSON_MIME_TYPE = "application/json"
34
+ JSON_HEADERS = {"Accept": JSON_MIME_TYPE}
35
+
33
36
  ID_URIS = {
34
37
  "orcid": "https://orcid.org/",
35
38
  "ror": "https://ror.org/",
@@ -57,7 +60,7 @@ def check_orcid(orcid: str) -> typing.Dict:
57
60
  metadata from the given ID
58
61
  """
59
62
  orcid = orcid.replace(ID_URIS["orcid"], "")
60
- _header = {"Accept": "application/json"}
63
+ _header = JSON_HEADERS
61
64
  _url = urllib.parse.urljoin(QUERY_URLS["orcid"], orcid)
62
65
  requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
63
66
  _response = requests.get(_url, headers=_header, verify=False, allow_redirects=True)
@@ -95,7 +98,7 @@ def check_github(github: str) -> typing.Dict:
95
98
  typing.Dict
96
99
  metadata from the given ID
97
100
  """
98
- _header = {"Accept": "application/json"}
101
+ _header = JSON_HEADERS
99
102
  _url = urllib.parse.urljoin(QUERY_URLS["github"], github)
100
103
  requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
101
104
  _response = requests.get(_url, headers=_header, verify=False, allow_redirects=True)
@@ -104,7 +107,7 @@ def check_github(github: str) -> typing.Dict:
104
107
 
105
108
  if _response.status_code == 403:
106
109
  time.sleep(3)
107
- _header = {"Accept": "application/json", "User-Agent": str(UserAgent().chrome)}
110
+ _header = {"Accept": JSON_MIME_TYPE, "User-Agent": str(UserAgent().chrome)}
108
111
  _response = requests.get(
109
112
  _url, headers=_header, verify=False, allow_redirects=True
110
113
  )
@@ -149,7 +152,7 @@ def check_gitlab(gitlab: str, gitlab_url: str = "https://gitlab.com/") -> typing
149
152
 
150
153
  if _response.status_code == 403:
151
154
  time.sleep(3)
152
- _header = {"Accept": "application/json", "User-Agent": str(UserAgent().chrome)}
155
+ _header = {"Accept": JSON_MIME_TYPE, "User-Agent": str(UserAgent().chrome)}
153
156
  _response = requests.get(
154
157
  _url, headers=_header, verify=False, allow_redirects=True
155
158
  )
@@ -99,5 +99,5 @@ class LevelFormatter(logging.Formatter):
99
99
 
100
100
  def format(self, record: logging.LogRecord) -> str:
101
101
  idx = bisect(self.formats, (record.levelno,), hi=len(self.formats) - 1)
102
- level, formatter = self.formats[idx]
102
+ _, formatter = self.formats[idx] # Tuple unpacking level, then formatter
103
103
  return formatter.format(record)
@@ -632,7 +632,7 @@ def get_author_exists(registry_uri, token=None, name=None, identifier=None) -> s
632
632
  The url of the author if they exist else None
633
633
  """
634
634
  if not name and not identifier:
635
- return {}
635
+ return ""
636
636
  if not token:
637
637
  token = local_token()
638
638
  _params = {}
@@ -643,7 +643,7 @@ def get_author_exists(registry_uri, token=None, name=None, identifier=None) -> s
643
643
  _author_exists = get(registry_uri, "author", token, params=_params)
644
644
  if _author_exists:
645
645
  return _author_exists[0]["url"]
646
- return {}
646
+ return ""
647
647
 
648
648
 
649
649
  def get_auth_provider(registry_uri: str, token: str = None) -> str:
@@ -350,13 +350,12 @@ def _get_new_url(
350
350
  _new_obj_data["authors"].append(_new_author_url)
351
351
  _filters["authors"].append(fdp_req.get_obj_id_from_url(_new_author_url))
352
352
 
353
- if _obj_type == "author":
354
- if "identifier" in _new_obj_data:
355
- _author = fdp_req.get_author_exists(
356
- dest_uri, token=dest_token, identifier=_new_obj_data["identifier"]
357
- )
358
- if _author:
359
- return _author
353
+ if _obj_type == "author" and "identifier" in _new_obj_data:
354
+ _author = fdp_req.get_author_exists(
355
+ dest_uri, token=dest_token, identifier=_new_obj_data["identifier"]
356
+ )
357
+ if _author:
358
+ return _author
360
359
 
361
360
  return fdp_req.post_else_get(
362
361
  dest_uri,
@@ -402,6 +401,8 @@ def sync_user_author(
402
401
  author_url: str,
403
402
  remote_user: str,
404
403
  ) -> None:
404
+ _ = origin_uri # prevent unused variable warning
405
+ _ = origin_token # prevent unused variable warning
405
406
  current_user = fdp_req.get(
406
407
  dest_uri, "users", dest_token, params={"username": remote_user}
407
408
  )
@@ -64,6 +64,13 @@ import fair.user_config as fdp_user
64
64
  import fair.logging as fdp_logging
65
65
  import fair.registry.storage as fdp_store
66
66
 
67
+ GLOBAL_CONFIG_MESSAGE = (
68
+ "Setup will now ask you questions regarding the global configuration"
69
+ )
70
+ REPO_CONFIG_MESSAGE = (
71
+ "Setup will now ask you questions regarding this repo configuration"
72
+ )
73
+
67
74
 
68
75
  class FAIR:
69
76
  """
@@ -1170,17 +1177,13 @@ class FAIR:
1170
1177
  if not os.path.exists(fdp_com.global_fdpconfig()):
1171
1178
  try:
1172
1179
  if not self._testing:
1173
- click.echo(
1174
- "Setup will now ask you questions regarding the global configuration"
1175
- )
1180
+ click.echo(GLOBAL_CONFIG_MESSAGE)
1176
1181
  self._global_config = fdp_conf.global_config_query(registry, local)
1177
1182
  except (fdp_exc.CLIConfigurationError, click.Abort) as e:
1178
1183
  self._clean_reset(_fair_dir, e)
1179
1184
  try:
1180
1185
  if not self._testing:
1181
- click.echo(
1182
- "Setup will now ask you questions regarding this repo configuration"
1183
- )
1186
+ click.echo(REPO_CONFIG_MESSAGE)
1184
1187
  self._local_config = fdp_conf.local_config_query(
1185
1188
  self._global_config,
1186
1189
  first_time_setup=_first_time,
@@ -1191,9 +1194,7 @@ class FAIR:
1191
1194
  elif not using:
1192
1195
  try:
1193
1196
  if not self._testing:
1194
- click.echo(
1195
- "Setup will now ask you questions regarding this repo configuration"
1196
- )
1197
+ click.echo(REPO_CONFIG_MESSAGE)
1197
1198
  self._local_config = fdp_conf.local_config_query(
1198
1199
  self._global_config, local=local
1199
1200
  )
@@ -1208,14 +1209,10 @@ class FAIR:
1208
1209
  yaml.dump(self._global_config, f)
1209
1210
  else:
1210
1211
  if not self._testing:
1211
- click.echo(
1212
- "Setup will now ask you questions regarding the global configuration"
1213
- )
1212
+ click.echo(GLOBAL_CONFIG_MESSAGE)
1214
1213
  self._global_config = fdp_conf.read_global_fdpconfig()
1215
1214
  if not self._testing:
1216
- click.echo(
1217
- "Setup will now ask you questions regarding this repo configuration"
1218
- )
1215
+ click.echo(REPO_CONFIG_MESSAGE)
1219
1216
  self._local_config = fdp_conf.read_local_fdpconfig(self._session_loc)
1220
1217
 
1221
1218
  if export_as:
@@ -171,7 +171,7 @@ class Stager:
171
171
  self.add_to_staging(job_id, "job")
172
172
  self.change_stage_status(job_id, "job", stage)
173
173
 
174
- def find_registry_entry_for_file(self, local_uri: str, file_path: str) -> str:
174
+ def find_registry_entry_for_file(self, local_uri: str, file_path: str) -> dict:
175
175
  """Performs a rough search for a file in the local registry
176
176
 
177
177
  Parameters
@@ -312,7 +312,7 @@ class Stager:
312
312
 
313
313
  _config_url = self.find_registry_entry_for_file(
314
314
  fdp_conf.get_local_uri(), _config_rel_path
315
- )["url"]
315
+ ).get("url")
316
316
 
317
317
  # Check for job script file
318
318
  _config_yaml = os.path.join(_directory, fdp_com.USER_CONFIG_FILE)
@@ -355,7 +355,9 @@ class Stager:
355
355
  _rel_script_path = _script_path.split(fdp_com.JOBS_DIR)[1]
356
356
  _rel_script_path = f"{fdp_com.JOBS_DIR}{_rel_script_path}"
357
357
 
358
- result = self.find_registry_entry_for_file(local_uri, _rel_script_path)["url"]
358
+ result = self.find_registry_entry_for_file(local_uri, _rel_script_path).get(
359
+ "url"
360
+ )
359
361
 
360
362
  self._logger.debug("Script URL: %s", result)
361
363
 
@@ -318,7 +318,7 @@ class JobConfiguration(MutableMapping):
318
318
  for register_entry in register_block:
319
319
  _new_entry = register_entry.copy()
320
320
  if "namespace_name" not in register_entry:
321
- if not "use" in register_entry:
321
+ if "use" not in register_entry:
322
322
  _new_entry["use"] = {}
323
323
  else:
324
324
  if "namespace" in register_entry["use"]:
@@ -569,8 +569,8 @@ class JobConfiguration(MutableMapping):
569
569
 
570
570
  if not _cmd or not _out_file:
571
571
  raise fdp_exc.UserConfigError(
572
- "Configuration file must contain either a valid "
573
- "'script' or 'script_path' entry under 'run_metadata'"
572
+ "Configuration file must contain either a valid \
573
+ 'script' or 'script_path' entry under 'run_metadata'"
574
574
  )
575
575
 
576
576
  self.set_script(_out_file)
@@ -24,7 +24,7 @@ classifiers = [
24
24
  ]
25
25
  description = "Synchronization interface for the SCRC FAIR Data Pipeline registry"
26
26
  name = "fair-cli"
27
- version = "0.9.7"
27
+ version = "0.9.8"
28
28
 
29
29
  homepage = "https://www.fairdatapipeline.org/"
30
30
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes