data_pipeline_api 0.7.5__tar.gz → 0.7.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: data-pipeline-api
3
- Version: 0.7.5
3
+ Version: 0.7.7
4
4
  Summary: Python api to interact with the Fair Data Pipeline
5
5
  Home-page: https://www.fairdatapipeline.org/
6
6
  License: GNU General Public License v3.0
@@ -56,9 +56,10 @@ Assume FDP_CONFIG_DIR, storage_locations and objects have been set by CLI tool
56
56
  import os
57
57
  import fairdatapipeline as pipeline
58
58
 
59
- token = os.environ.get('FDP_LOCAL_TOKEN')
60
- config_path = os.environ.get('FDP_CONFIG_DIR') + '/config.yaml'
61
- script_path = os.environ.get('FDP_CONFIG_DIR') + '/script.sh'
59
+ token = os.environ['FDP_LOCAL_TOKEN']
60
+ config_dir = os.environ['FDP_CONFIG_DIR']
61
+ config_path = os.path.join(config_dir, 'config.yaml')
62
+ script_path = os.path.join(config_dir, 'script.sh')
62
63
 
63
64
  handle = pipeline.initialise(token, config_path, script_path)
64
65
 
@@ -33,9 +33,10 @@ Assume FDP_CONFIG_DIR, storage_locations and objects have been set by CLI tool
33
33
  import os
34
34
  import fairdatapipeline as pipeline
35
35
 
36
- token = os.environ.get('FDP_LOCAL_TOKEN')
37
- config_path = os.environ.get('FDP_CONFIG_DIR') + '/config.yaml'
38
- script_path = os.environ.get('FDP_CONFIG_DIR') + '/script.sh'
36
+ token = os.environ['FDP_LOCAL_TOKEN']
37
+ config_dir = os.environ['FDP_CONFIG_DIR']
38
+ config_path = os.path.join(config_dir, 'config.yaml')
39
+ script_path = os.path.join(config_dir, 'script.sh')
39
40
 
40
41
  handle = pipeline.initialise(token, config_path, script_path)
41
42
 
@@ -225,10 +225,30 @@ def post_storage_root(
225
225
  """
226
226
  if "local" in data and data["local"]:
227
227
  data["root"] = "file://" + data["root"]
228
- if data["root"][-1] != "/":
228
+ if data["root"][-1] != os.sep:
229
+ data["root"] = data["root"] + os.sep
230
+ elif data["root"][-1] != "/":
229
231
  data["root"] = data["root"] + "/"
230
232
  return post_entry(url, "storage_root", data, token, api_version)
231
233
 
234
+ def post_file_type(
235
+ url: str, data: dict, token: str, api_version: str = "1.0.0"
236
+ ) -> dict:
237
+ """
238
+ Internal wrapper function to return check if a file_type already exists and return it.
239
+ """
240
+ if not "extension" in data and data["extension"]:
241
+ raise ValueError("error file_type name not specified")
242
+ file_type_exists = get_entry(url= url,
243
+ endpoint= "file_type",
244
+ query= {"extension": data["extension"]},
245
+ api_version= api_version)
246
+ if file_type_exists : return file_type_exists[0]
247
+ return post_entry(url= url,
248
+ endpoint= "file_type",
249
+ data= data,
250
+ token= token,
251
+ api_version= api_version)
232
252
 
233
253
  def remove_local_from_root(root: str) -> str:
234
254
  """
@@ -82,11 +82,10 @@ def initialise(token: str, config: str, script: str) -> dict:
82
82
  config_location_url = config_location_response["url"]
83
83
 
84
84
  # Configure Yaml File Type
85
- config_filetype_response = fdp_utils.post_entry(
85
+ config_filetype_response = fdp_utils.post_file_type(
86
86
  token=token,
87
87
  url=registry_url,
88
- endpoint="file_type",
89
- data={"name": "yaml", "extension": "yaml"},
88
+ data={"name": "YAML Document", "extension": "yaml"},
90
89
  api_version=api_version,
91
90
  )
92
91
  config_filetype_url = config_filetype_response["url"]
@@ -174,14 +173,14 @@ def initialise(token: str, config: str, script: str) -> dict:
174
173
  )
175
174
 
176
175
  script_location_url = script_location_response["url"]
176
+ script_file_type = os.path.basename(script).split(".")[-1]
177
177
 
178
178
  # TODO: Change to Batch?
179
179
  # Create Script File Type
180
- script_filetype_response = fdp_utils.post_entry(
180
+ script_filetype_response = fdp_utils.post_file_type(
181
181
  token=token,
182
182
  url=registry_url,
183
- endpoint="file_type",
184
- data={"name": "py", "extension": "py"},
183
+ data={"name": "python submission script", "extension": script_file_type},
185
184
  api_version=api_version,
186
185
  )
187
186
 
@@ -478,23 +477,11 @@ def finalise(token: str, handle: dict) -> None:
478
477
 
479
478
  file_type = os.path.basename(new_path).split(".")[-1]
480
479
 
481
- file_type_exists = fdp_utils.get_entry(
480
+ file_type_url = fdp_utils.post_file_type(
481
+ token=token,
482
482
  url=registry_url,
483
- endpoint="file_type",
484
- query={"extension": file_type},
483
+ data={"name": file_type, "extension": file_type},
485
484
  api_version=api_version,
486
- )
487
-
488
- if file_type_exists:
489
- entry = fdp_utils.get_first_entry(file_type_exists)
490
- file_type_url = entry["url"]
491
- else:
492
- file_type_url = fdp_utils.post_entry(
493
- token=token,
494
- url=registry_url,
495
- endpoint="file_type",
496
- data={"name": file_type, "extension": file_type},
497
- api_version=api_version,
498
485
  )["url"]
499
486
 
500
487
  data_product_exists = fdp_utils.get_entry(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "data_pipeline_api"
3
- version = "0.7.5"
3
+ version = "0.7.7"
4
4
  description = "Python api to interact with the Fair Data Pipeline"
5
5
  authors = [
6
6
  "Ryan J Field <ryan.field@glasgow.ac.uk>",
@@ -77,7 +77,7 @@ line_length = 79
77
77
  line-length = 79
78
78
 
79
79
  [tool.pytest.ini_options]
80
- addopts = '-s -v --cov=fairdatapipeline --cov-report=html --cov-report=term'
80
+ addopts = '-s -v --cov=data_pipeline_api --cov-report=html --cov-report=term'
81
81
  markers = [
82
82
  "pipeline: tests for 'pipeline' module ",
83
83
  "issue: tests for raising issues ",
@@ -16,9 +16,9 @@ install_requires = \
16
16
 
17
17
  setup_kwargs = {
18
18
  'name': 'data-pipeline-api',
19
- 'version': '0.7.5',
19
+ 'version': '0.7.7',
20
20
  'description': 'Python api to interact with the Fair Data Pipeline',
21
- 'long_description': "# pyDataPipeline\n\n[![pyDataPipeline](https://github.com/FAIRDataPipeline/pyDataPipeline/actions/workflows/pyDataPipeline.yaml/badge.svg?branch=dev)](https://github.com/FAIRDataPipeline/pyDataPipeline/actions/workflows/pyDataPipeline.yaml)\n[![codecov](https://codecov.io/gh/FAIRDataPipeline/pyDataPipeline/branch/dev/graph/badge.svg?token=Eax5AmrDxx)](https://codecov.io/gh/FAIRDataPipeline/pyDataPipeline)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5562602.svg)](https://doi.org/10.5281/zenodo.5562602)\n[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5461/badge)](https://bestpractices.coreinfrastructure.org/projects/5461)\n\nWelcome to pyDataPipeline a Python api to interact with the Fair Data Pipeline.\n\nFull documention of the pyDataPipeline is avaialable at [https://www.fairdatapipeline.org/pyDataPipeline/](https://www.fairdatapipeline.org/pyDataPipeline/)\n\n## Installation\npyDataPipeline can be installed from PyPi:\n```\npip3 install data-pipeline-api\n```\n\nOr from the Repository:\n```\ngit clone https://github.com/FAIRDataPipeline/pythonFDP.git\n\ngit checkout dev\n\npip3 install -e .\n```\n**NB. PyDataPipeline requires Python3.**\n\n## Example submission_script\n\nAssume FDP_CONFIG_DIR, storage_locations and objects have been set by CLI tool\n\n```\nimport os\nimport fairdatapipeline as pipeline\n\ntoken = os.environ.get('FDP_LOCAL_TOKEN')\nconfig_path = os.environ.get('FDP_CONFIG_DIR') + '/config.yaml'\nscript_path = os.environ.get('FDP_CONFIG_DIR') + '/script.sh'\n\nhandle = pipeline.initialise(token, config_path, script_path)\n\npipeline.finalise(token, handle)\n\n```\n\n## SEIRS Model Example\n\nThe SEIRS Model Example is available at: [https://www.fairdatapipeline.org/pyDataPipeline/examples/SEIRS.html](https://www.fairdatapipeline.org/pyDataPipeline/examples/SEIRS.html)\n",
21
+ 'long_description': "# pyDataPipeline\n\n[![pyDataPipeline](https://github.com/FAIRDataPipeline/pyDataPipeline/actions/workflows/pyDataPipeline.yaml/badge.svg?branch=dev)](https://github.com/FAIRDataPipeline/pyDataPipeline/actions/workflows/pyDataPipeline.yaml)\n[![codecov](https://codecov.io/gh/FAIRDataPipeline/pyDataPipeline/branch/dev/graph/badge.svg?token=Eax5AmrDxx)](https://codecov.io/gh/FAIRDataPipeline/pyDataPipeline)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5562602.svg)](https://doi.org/10.5281/zenodo.5562602)\n[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5461/badge)](https://bestpractices.coreinfrastructure.org/projects/5461)\n\nWelcome to pyDataPipeline a Python api to interact with the Fair Data Pipeline.\n\nFull documention of the pyDataPipeline is avaialable at [https://www.fairdatapipeline.org/pyDataPipeline/](https://www.fairdatapipeline.org/pyDataPipeline/)\n\n## Installation\npyDataPipeline can be installed from PyPi:\n```\npip3 install data-pipeline-api\n```\n\nOr from the Repository:\n```\ngit clone https://github.com/FAIRDataPipeline/pythonFDP.git\n\ngit checkout dev\n\npip3 install -e .\n```\n**NB. PyDataPipeline requires Python3.**\n\n## Example submission_script\n\nAssume FDP_CONFIG_DIR, storage_locations and objects have been set by CLI tool\n\n```\nimport os\nimport fairdatapipeline as pipeline\n\ntoken = os.environ['FDP_LOCAL_TOKEN']\nconfig_dir = os.environ['FDP_CONFIG_DIR']\nconfig_path = os.path.join(config_dir, 'config.yaml')\nscript_path = os.path.join(config_dir, 'script.sh')\n\nhandle = pipeline.initialise(token, config_path, script_path)\n\npipeline.finalise(token, handle)\n\n```\n\n## SEIRS Model Example\n\nThe SEIRS Model Example is available at: [https://www.fairdatapipeline.org/pyDataPipeline/examples/SEIRS.html](https://www.fairdatapipeline.org/pyDataPipeline/examples/SEIRS.html)\n",
22
22
  'author': 'Ryan J Field',
23
23
  'author_email': 'ryan.field@glasgow.ac.uk',
24
24
  'maintainer': None,