geoseeq 0.4.1__tar.gz → 0.5.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. {geoseeq-0.4.1 → geoseeq-0.5.1}/PKG-INFO +1 -1
  2. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/main.py +2 -2
  3. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/shared_params/common_state.py +1 -1
  4. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/shared_params/opts_and_args.py +1 -1
  5. geoseeq-0.5.1/geoseeq/constants.py +10 -0
  6. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/from_blobs.py +10 -0
  7. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/from_ids.py +10 -0
  8. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/from_names.py +10 -0
  9. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/from_uuids.py +12 -1
  10. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/resolvers.py +4 -0
  11. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/knex.py +35 -2
  12. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/utils.py +36 -0
  13. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq.egg-info/PKG-INFO +1 -1
  14. {geoseeq-0.4.1 → geoseeq-0.5.1}/setup.py +1 -1
  15. geoseeq-0.4.1/geoseeq/constants.py +0 -2
  16. {geoseeq-0.4.1 → geoseeq-0.5.1}/LICENSE +0 -0
  17. {geoseeq-0.4.1 → geoseeq-0.5.1}/README.md +0 -0
  18. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/__init__.py +0 -0
  19. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/app.py +0 -0
  20. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/blob_constructors.py +0 -0
  21. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/bulk_creators.py +0 -0
  22. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/__init__.py +0 -0
  23. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/constants.py +0 -0
  24. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/copy.py +0 -0
  25. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/detail.py +0 -0
  26. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/download.py +0 -0
  27. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/fastq_utils.py +0 -0
  28. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/get_eula.py +0 -0
  29. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/manage.py +0 -0
  30. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/progress_bar.py +0 -0
  31. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/run.py +0 -0
  32. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/search.py +0 -0
  33. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/shared_params/__init__.py +0 -0
  34. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/shared_params/config.py +0 -0
  35. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/shared_params/id_handlers.py +0 -0
  36. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/shared_params/obj_getters.py +0 -0
  37. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/upload/__init__.py +0 -0
  38. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/upload/upload.py +0 -0
  39. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/upload/upload_advanced.py +0 -0
  40. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/upload/upload_reads.py +0 -0
  41. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/user.py +0 -0
  42. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/utils.py +0 -0
  43. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/cli/view.py +0 -0
  44. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/contrib/__init__.py +0 -0
  45. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/contrib/ncbi/__init__.py +0 -0
  46. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/contrib/ncbi/api.py +0 -0
  47. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/contrib/ncbi/bioproject.py +0 -0
  48. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/contrib/ncbi/cli.py +0 -0
  49. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/contrib/ncbi/setup_logging.py +0 -0
  50. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/file_system_cache.py +0 -0
  51. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/__init__.py +0 -0
  52. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/id_constructors/utils.py +0 -0
  53. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/organization.py +0 -0
  54. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/pipeline.py +0 -0
  55. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/__init__.py +0 -0
  56. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/constants.py +0 -0
  57. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/highcharts.py +0 -0
  58. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/map/__init__.py +0 -0
  59. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/map/base_layer.py +0 -0
  60. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/map/map.py +0 -0
  61. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/map/overlay.py +0 -0
  62. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/plotting/selectable.py +0 -0
  63. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/project.py +0 -0
  64. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/remote_object.py +0 -0
  65. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/__init__.py +0 -0
  66. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/bioinfo.py +0 -0
  67. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/file_download.py +0 -0
  68. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/file_upload.py +0 -0
  69. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/result_file.py +0 -0
  70. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/result_folder.py +0 -0
  71. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/result/utils.py +0 -0
  72. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/sample.py +0 -0
  73. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/search.py +0 -0
  74. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/user.py +0 -0
  75. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/__init__.py +0 -0
  76. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/checksum.py +0 -0
  77. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/cli.py +0 -0
  78. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/clone.py +0 -0
  79. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/constants.py +0 -0
  80. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/vc_cache.py +0 -0
  81. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/vc_dir.py +0 -0
  82. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/vc_sample.py +0 -0
  83. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/vc/vc_stub.py +0 -0
  84. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq/work_orders.py +0 -0
  85. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq.egg-info/SOURCES.txt +0 -0
  86. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq.egg-info/dependency_links.txt +0 -0
  87. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq.egg-info/entry_points.txt +0 -0
  88. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq.egg-info/requires.txt +0 -0
  89. {geoseeq-0.4.1 → geoseeq-0.5.1}/geoseeq.egg-info/top_level.txt +0 -0
  90. {geoseeq-0.4.1 → geoseeq-0.5.1}/pyproject.toml +0 -0
  91. {geoseeq-0.4.1 → geoseeq-0.5.1}/setup.cfg +0 -0
  92. {geoseeq-0.4.1 → geoseeq-0.5.1}/tests/__init__.py +0 -0
  93. {geoseeq-0.4.1 → geoseeq-0.5.1}/tests/test_api_client.py +0 -0
  94. {geoseeq-0.4.1 → geoseeq-0.5.1}/tests/test_plotting.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geoseeq
3
- Version: 0.4.1
3
+ Version: 0.5.1
4
4
  Summary: # Geoseeq API Client
5
5
  Author: David C. Danko
6
6
  Author-email: dcdanko@biotia.io
@@ -13,7 +13,7 @@ from .view import cli_view
13
13
  from .search import cli_search
14
14
  from geoseeq.vc.cli import cli_vc
15
15
  from geoseeq.knex import DEFAULT_ENDPOINT
16
- from .shared_params.config import set_profile
16
+ from geoseeq.utils import set_profile
17
17
  from .shared_params.opts_and_args import overwrite_option
18
18
  from .detail import cli_detail
19
19
  from .run import cli_app
@@ -53,7 +53,7 @@ def version():
53
53
  Use of this tool implies acceptance of the GeoSeeq End User License Agreement.
54
54
  Run `geoseeq eula show` to view the EULA.
55
55
  """
56
- click.echo('0.4.1') # remember to update setup
56
+ click.echo('0.5.1') # remember to update setup
57
57
 
58
58
 
59
59
  @main.group('advanced')
@@ -4,7 +4,7 @@ import click
4
4
  from geoseeq.knex import DEFAULT_ENDPOINT
5
5
 
6
6
  from geoseeq import Knex
7
- from .config import load_profile
7
+ from geoseeq.utils import load_auth_profile
8
8
 
9
9
  logger = logging.getLogger('geoseeq_api')
10
10
 
@@ -24,4 +24,4 @@ org_id_arg = click.argument('org_id', nargs=1)
24
24
  project_id_arg = click.argument('project_id', nargs=1)
25
25
  pipeline_id_arg = click.argument('pipeline_id', nargs=1)
26
26
  sample_ids_arg = click.argument('sample_ids', nargs=-1)
27
- folder_id_arg = click.argument('folder_id', nargs=1)
27
+ folder_id_arg = click.argument('folder_id', nargs=1)
@@ -0,0 +1,10 @@
1
+ from os import environ
2
+ from os.path import join
3
+
4
+ FIVE_MB = 5 * (1024 ** 2)
5
+ FASTQ_MODULE_NAMES = ['short_read::paired_end', 'short_read::single_end', 'long_read::nanopore']
6
+ DEFAULT_ENDPOINT = "https://backend.geoseeq.com"
7
+
8
+ CONFIG_FOLDER = environ.get("XDG_CONFIG_HOME", join(environ["HOME"], ".config"))
9
+ CONFIG_DIR = environ.get("GEOSEEQ_CONFIG_DIR", join(CONFIG_FOLDER, "geoseeq"))
10
+ PROFILES_PATH = join(CONFIG_DIR, "profiles.json")
@@ -1,6 +1,8 @@
1
1
  from geoseeq import GeoseeqNotFoundError
2
+ from geoseeq.knex import with_knex
2
3
 
3
4
 
5
+ @with_knex
4
6
  def org_from_blob(knex, blob, already_fetched=True, modified=False):
5
7
  """Return an Organization object from a blob."""
6
8
  from geoseeq.organization import Organization # import here to avoid circular import
@@ -11,6 +13,7 @@ def org_from_blob(knex, blob, already_fetched=True, modified=False):
11
13
  return org
12
14
 
13
15
 
16
+ @with_knex
14
17
  def project_from_blob(knex, blob, already_fetched=True, modified=False):
15
18
  """Return a Project object from a blob."""
16
19
  org = org_from_blob(
@@ -27,6 +30,7 @@ def project_from_blob(knex, blob, already_fetched=True, modified=False):
27
30
  sample_group_from_blob = project_from_blob # Alias
28
31
 
29
32
 
33
+ @with_knex
30
34
  def sample_from_blob(knex, blob, already_fetched=True, modified=False):
31
35
  """Return a Sample object from a blob."""
32
36
  lib = sample_group_from_blob(
@@ -40,6 +44,7 @@ def sample_from_blob(knex, blob, already_fetched=True, modified=False):
40
44
  return sample
41
45
 
42
46
 
47
+ @with_knex
43
48
  def project_result_folder_from_blob(knex, blob, already_fetched=True, modified=False):
44
49
  """Return a ProjectResultFolder object from a blob."""
45
50
  group = project_from_blob(
@@ -58,6 +63,7 @@ def project_result_folder_from_blob(knex, blob, already_fetched=True, modified=F
58
63
  sample_group_ar_from_blob = project_result_folder_from_blob # Alias
59
64
 
60
65
 
66
+ @with_knex
61
67
  def sample_result_folder_from_blob(knex, blob, already_fetched=True, modified=False):
62
68
  """Return a SampleResultFolder object from a blob."""
63
69
  sample = sample_from_blob(
@@ -76,6 +82,7 @@ def sample_result_folder_from_blob(knex, blob, already_fetched=True, modified=Fa
76
82
  sample_ar_from_blob = sample_result_folder_from_blob # Alias
77
83
 
78
84
 
85
+ @with_knex
79
86
  def sample_result_file_from_blob(knex, blob, already_fetched=True, modified=False):
80
87
  """Return a SampleResultFile object from a blob."""
81
88
  ar = sample_result_folder_from_blob(
@@ -92,6 +99,7 @@ def sample_result_file_from_blob(knex, blob, already_fetched=True, modified=Fals
92
99
  sample_ar_field_from_blob = sample_result_file_from_blob # Alias
93
100
 
94
101
 
102
+ @with_knex
95
103
  def project_result_file_from_blob(knex, blob, already_fetched=True, modified=False):
96
104
  """Return a ProjectResultFile object from a blob."""
97
105
  ar = project_result_folder_from_blob(
@@ -108,6 +116,7 @@ def project_result_file_from_blob(knex, blob, already_fetched=True, modified=Fal
108
116
  sample_group_ar_field_from_blob = project_result_file_from_blob # Alias
109
117
 
110
118
 
119
+ @with_knex
111
120
  def pipeline_from_blob(knex, blob, already_fetched=True, modified=False):
112
121
  """Return a Pipeline object from a blob."""
113
122
  from geoseeq.pipeline import Pipeline # import here to avoid circular import
@@ -120,6 +129,7 @@ def pipeline_from_blob(knex, blob, already_fetched=True, modified=False):
120
129
  app_from_blob = pipeline_from_blob # Alias
121
130
 
122
131
 
132
+ @with_knex
123
133
  def pipeline_run_from_blob(knex, blob, already_fetched=True, modified=False):
124
134
  """Return a Pipeline run object from a blob."""
125
135
  from geoseeq.pipeline import PipelineRun # import here to avoid circular import
@@ -22,6 +22,7 @@ from .from_names import (
22
22
  result_file_from_name,
23
23
  )
24
24
  from .utils import is_grn_or_uuid, is_name
25
+ from geoseeq.knex import with_knex
25
26
 
26
27
 
27
28
  def _generic_from_id(knex, id, from_uuid_func, from_name_func):
@@ -33,31 +34,37 @@ def _generic_from_id(knex, id, from_uuid_func, from_name_func):
33
34
  raise ValueError(f'"{id}" is not a GRN, UUID, or name')
34
35
 
35
36
 
37
+ @with_knex
36
38
  def org_from_id(knex, id):
37
39
  """Return the organization object which the id points to."""
38
40
  return _generic_from_id(knex, id, org_from_uuid, org_from_name)
39
41
 
40
42
 
43
+ @with_knex
41
44
  def project_from_id(knex, id):
42
45
  """Return the project object which the id points to."""
43
46
  return _generic_from_id(knex, id, project_from_uuid, project_from_name)
44
47
 
45
48
 
49
+ @with_knex
46
50
  def sample_from_id(knex, id):
47
51
  """Return the sample object which the id points to."""
48
52
  return _generic_from_id(knex, id, sample_from_uuid, sample_from_name)
49
53
 
50
54
 
55
+ @with_knex
51
56
  def sample_result_folder_from_id(knex, id):
52
57
  """Return the sample result folder object which the id points to."""
53
58
  return _generic_from_id(knex, id, sample_result_folder_from_uuid, sample_result_folder_from_name)
54
59
 
55
60
 
61
+ @with_knex
56
62
  def project_result_folder_from_id(knex, id):
57
63
  """Return the project result folder object which the id points to."""
58
64
  return _generic_from_id(knex, id, project_result_folder_from_uuid, project_result_folder_from_name)
59
65
 
60
66
 
67
+ @with_knex
61
68
  def result_folder_from_id(knex, id):
62
69
  """Return a result folder object which the id points to.
63
70
 
@@ -66,16 +73,19 @@ def result_folder_from_id(knex, id):
66
73
  return _generic_from_id(knex, id, result_folder_from_uuid, result_folder_from_name)
67
74
 
68
75
 
76
+ @with_knex
69
77
  def sample_result_file_from_id(knex, id):
70
78
  """Return the sample result file object which the id points to."""
71
79
  return _generic_from_id(knex, id, sample_result_file_from_uuid, sample_result_file_from_name)
72
80
 
73
81
 
82
+ @with_knex
74
83
  def project_result_file_from_id(knex, id):
75
84
  """Return the project result file object which the id points to."""
76
85
  return _generic_from_id(knex, id, project_result_file_from_uuid, project_result_file_from_name)
77
86
 
78
87
 
88
+ @with_knex
79
89
  def result_file_from_id(knex, id):
80
90
  """Return a result file object which the id points to.
81
91
 
@@ -14,8 +14,10 @@ This makes them more human-readable, but not reliable for permanent references.
14
14
  """
15
15
  from geoseeq.organization import Organization
16
16
  from geoseeq import GeoseeqNotFoundError
17
+ from geoseeq.knex import with_knex
17
18
 
18
19
 
20
+ @with_knex
19
21
  def org_from_name(knex, name):
20
22
  """Return the organization object which the name points to.
21
23
 
@@ -28,6 +30,7 @@ def org_from_name(knex, name):
28
30
  return org
29
31
 
30
32
 
33
+ @with_knex
31
34
  def project_from_name(knex, name):
32
35
  """Return the project object which the name points to.
33
36
 
@@ -41,6 +44,7 @@ def project_from_name(knex, name):
41
44
  return proj
42
45
 
43
46
 
47
+ @with_knex
44
48
  def sample_from_name(knex, name):
45
49
  """Return the sample object which the name points to.
46
50
 
@@ -54,6 +58,7 @@ def sample_from_name(knex, name):
54
58
  return sample
55
59
 
56
60
 
61
+ @with_knex
57
62
  def sample_result_folder_from_name(knex, name):
58
63
  """Return the sample result folder object which the name points to.
59
64
 
@@ -67,6 +72,7 @@ def sample_result_folder_from_name(knex, name):
67
72
  return ar
68
73
 
69
74
 
75
+ @with_knex
70
76
  def project_result_folder_from_name(knex, name):
71
77
  """Return the project result folder object which the name points to.
72
78
 
@@ -80,6 +86,7 @@ def project_result_folder_from_name(knex, name):
80
86
  return rf
81
87
 
82
88
 
89
+ @with_knex
83
90
  def result_folder_from_name(knex, name):
84
91
  """Return a result folder object which the name points to.
85
92
 
@@ -95,6 +102,7 @@ def result_folder_from_name(knex, name):
95
102
  return project_result_folder_from_name(knex, name)
96
103
 
97
104
 
105
+ @with_knex
98
106
  def sample_result_file_from_name(knex, name):
99
107
  """Return the sample result file object which the name points to.
100
108
 
@@ -108,6 +116,7 @@ def sample_result_file_from_name(knex, name):
108
116
  return r_file
109
117
 
110
118
 
119
+ @with_knex
111
120
  def project_result_file_from_name(knex, name):
112
121
  """Return the project result file object which the name points to.
113
122
 
@@ -121,6 +130,7 @@ def project_result_file_from_name(knex, name):
121
130
  return r_file
122
131
 
123
132
 
133
+ @with_knex
124
134
  def result_file_from_name(knex, name):
125
135
  """Return a result file object which the name points to.
126
136
 
@@ -1,8 +1,9 @@
1
1
  from geoseeq import GeoseeqNotFoundError
2
-
2
+ from geoseeq.knex import with_knex
3
3
  from .from_blobs import *
4
4
 
5
5
 
6
+ @with_knex
6
7
  def org_from_uuid(knex, uuid):
7
8
  """Return the organization object which the uuid points to."""
8
9
  blob = knex.get(f"organizations/{uuid}")
@@ -10,6 +11,7 @@ def org_from_uuid(knex, uuid):
10
11
  return org
11
12
 
12
13
 
14
+ @with_knex
13
15
  def project_from_uuid(knex, uuid):
14
16
  """Return the project object which the uuid points to."""
15
17
  blob = knex.get(f"sample_groups/{uuid}")
@@ -20,6 +22,7 @@ def project_from_uuid(knex, uuid):
20
22
  sample_group_from_uuid = project_from_uuid # Alias
21
23
 
22
24
 
25
+ @with_knex
23
26
  def sample_from_uuid(knex, uuid):
24
27
  """Return the sample object which the uuid points to."""
25
28
  blob = knex.get(f"samples/{uuid}")
@@ -27,6 +30,7 @@ def sample_from_uuid(knex, uuid):
27
30
  return sample
28
31
 
29
32
 
33
+ @with_knex
30
34
  def sample_result_folder_from_uuid(knex, uuid):
31
35
  """Return the sample result folder object which the uuid points to."""
32
36
  blob = knex.get(f"sample_ars/{uuid}")
@@ -37,6 +41,7 @@ def sample_result_folder_from_uuid(knex, uuid):
37
41
  sample_ar_from_uuid = sample_result_folder_from_uuid # Alias
38
42
 
39
43
 
44
+ @with_knex
40
45
  def project_result_folder_from_uuid(knex, uuid):
41
46
  """Return the project result folder object which the uuid points to."""
42
47
  blob = knex.get(f"sample_group_ars/{uuid}")
@@ -47,6 +52,7 @@ def project_result_folder_from_uuid(knex, uuid):
47
52
  sample_group_ar_from_uuid = project_result_folder_from_uuid # Alias
48
53
 
49
54
 
55
+ @with_knex
50
56
  def result_folder_from_uuid(knex, uuid):
51
57
  """Return a result folder object which the uuid points to.
52
58
 
@@ -58,6 +64,7 @@ def result_folder_from_uuid(knex, uuid):
58
64
  return project_result_folder_from_uuid(knex, uuid)
59
65
 
60
66
 
67
+ @with_knex
61
68
  def sample_result_file_from_uuid(knex, uuid):
62
69
  """Return the sample result file object which the uuid points to."""
63
70
  blob = knex.get(f"sample_ar_fields/{uuid}")
@@ -68,6 +75,7 @@ def sample_result_file_from_uuid(knex, uuid):
68
75
  sample_ar_field_from_uuid = sample_result_file_from_uuid # Alias
69
76
 
70
77
 
78
+ @with_knex
71
79
  def project_result_file_from_uuid(knex, uuid):
72
80
  """Return the project result file object which the uuid points to."""
73
81
  blob = knex.get(f"sample_group_ar_fields/{uuid}")
@@ -78,6 +86,7 @@ def project_result_file_from_uuid(knex, uuid):
78
86
  sample_group_ar_field_from_uuid = project_result_file_from_uuid # Alias
79
87
 
80
88
 
89
+ @with_knex
81
90
  def result_file_from_uuid(knex, uuid):
82
91
  """Return a result file object which the uuid points to.
83
92
 
@@ -89,6 +98,7 @@ def result_file_from_uuid(knex, uuid):
89
98
  return project_result_file_from_uuid(knex, uuid)
90
99
 
91
100
 
101
+ @with_knex
92
102
  def pipeline_from_uuid(knex, uuid):
93
103
  """Return the pipeline object which the uuid points to."""
94
104
  blob = knex.get(f"pipelines/{uuid}")
@@ -99,6 +109,7 @@ def pipeline_from_uuid(knex, uuid):
99
109
  app_from_uuid = pipeline_from_uuid # Alias
100
110
 
101
111
 
112
+ @with_knex
102
113
  def pipeline_run_from_uuid(knex, uuid):
103
114
  """Return a pipeline run object which the uuid points to."""
104
115
  blob = knex.get(f"app_runs/{uuid}")
@@ -22,8 +22,10 @@ from .from_names import (
22
22
  result_file_from_name,
23
23
  )
24
24
  from .utils import is_name, is_grn
25
+ from geoseeq.knex import with_knex
25
26
 
26
27
 
28
+ @with_knex
27
29
  def resolve_id(knex, id):
28
30
  """Return the object which the id points to."""
29
31
  if is_grn(id):
@@ -33,6 +35,7 @@ def resolve_id(knex, id):
33
35
  raise ValueError(f'"{id}" is not a GRN, or name. UUIDs cannot be resolved without a type')
34
36
 
35
37
 
38
+ @with_knex
36
39
  def resolve_name(knex, name):
37
40
  """Return the object which the name points to."""
38
41
  assert is_name(name), f'"{name}" is not a name'
@@ -56,6 +59,7 @@ def resolve_name(knex, name):
56
59
  raise GeoseeqNotFoundError(f'Name "{name}" not found')
57
60
 
58
61
 
62
+ @with_knex
59
63
  def resolve_grn(knex, grn):
60
64
  """Return the object which the grn points to."""
61
65
  assert is_grn(grn), f'"{grn}" is not a GRN'
@@ -2,8 +2,8 @@ import logging
2
2
  import requests
3
3
  from os import environ
4
4
  from .file_system_cache import FileSystemCache
5
-
6
- DEFAULT_ENDPOINT = "https://backend.geoseeq.com"
5
+ from geoseeq.utils import load_auth_profile
6
+ from geoseeq.constants import DEFAULT_ENDPOINT
7
7
 
8
8
 
9
9
  logger = logging.getLogger("geoseeq_api") # Same name as calling module
@@ -205,3 +205,36 @@ class Knex:
205
205
  response = self.sess.delete(f"{self.endpoint_url}/{url}", json=json)
206
206
  logger.debug(f"DELETE request response:\n{response}")
207
207
  return self._handle_response(response, json_response=False, **kwargs)
208
+
209
+ @classmethod
210
+ def load_profile(cls, profile=""):
211
+ """Return a knex authenticated with a profile."""
212
+ endpoint, token = load_auth_profile(profile)
213
+ knex = cls(endpoint)
214
+ knex.add_api_token(token)
215
+ return knex
216
+
217
+
218
+ def with_knex(func):
219
+ def wrapper(*args, **kwargs):
220
+ # check if any of the arguments are a knex instance
221
+ any_knex = any([isinstance(arg, Knex) for arg in args])
222
+ if any_knex:
223
+ return func(*args, **kwargs)
224
+ else:
225
+ varnames = [
226
+ varname for varname in func.__code__.co_varnames
227
+ if varname != "knex"
228
+ ]
229
+ kwargs.update(zip(varnames, args))
230
+ if "knex" not in kwargs:
231
+ profile = kwargs.pop("profile", "")
232
+ kwargs['knex'] = Knex.load_profile(profile=profile)
233
+ # reorder kwargs to match the function signature
234
+ reordered = {
235
+ key: kwargs[key] for key in func.__code__.co_varnames
236
+ if key in kwargs
237
+ }
238
+ return func(**reordered)
239
+ return wrapper
240
+
@@ -4,11 +4,47 @@ import logging
4
4
  from ftplib import FTP
5
5
  from threading import Timer
6
6
  from .file_system_cache import FileSystemCache
7
+ from os.path import join, exists
8
+ import json
9
+ from os import environ, makedirs
10
+ from .constants import CONFIG_DIR, PROFILES_PATH, DEFAULT_ENDPOINT
7
11
 
8
12
  logger = logging.getLogger('geoseeq_api') # Same name as calling module
9
13
  logger.addHandler(logging.NullHandler()) # No output unless configured by calling program
10
14
 
11
15
 
16
+ def load_auth_profile(profile=""):
17
+ """Return an endpoit and a token"""
18
+ profile = profile or "__default__"
19
+ with open(PROFILES_PATH, "r") as f:
20
+ profiles = json.load(f)
21
+ if profile in profiles:
22
+ return profiles[profile]["endpoint"], profiles[profile]["token"]
23
+ raise KeyError(f"Profile {profile} not found.")
24
+
25
+
26
+ def set_profile(token, endpoint=DEFAULT_ENDPOINT, profile="", overwrite=False):
27
+ """Write a profile to a config file.
28
+
29
+ Raises KeyError if profile already exists.
30
+ """
31
+ if not exists(PROFILES_PATH):
32
+ makedirs(CONFIG_DIR)
33
+ with open(PROFILES_PATH, "w") as f:
34
+ json.dump({}, f)
35
+ with open(PROFILES_PATH, "r") as f:
36
+ profiles = json.load(f)
37
+ profile = profile or "__default__"
38
+ if profile in profiles and not overwrite:
39
+ raise KeyError(f"Profile {profile} already exists.")
40
+ profiles[profile] = {
41
+ "token": token,
42
+ "endpoint": endpoint,
43
+ }
44
+ with open(PROFILES_PATH, "w") as f:
45
+ json.dump(profiles, f, indent=4)
46
+
47
+
12
48
  def paginated_iterator(knex, initial_url, error_handler=None):
13
49
  cache = FileSystemCache()
14
50
  result = cache.get_cached_blob(initial_url)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geoseeq
3
- Version: 0.4.1
3
+ Version: 0.5.1
4
4
  Summary: # Geoseeq API Client
5
5
  Author: David C. Danko
6
6
  Author-email: dcdanko@biotia.io
@@ -5,7 +5,7 @@ import setuptools
5
5
 
6
6
  setuptools.setup(
7
7
  name='geoseeq',
8
- version='0.4.1', # remember to update version string in CLI as well
8
+ version='0.5.1', # remember to update version string in CLI as well
9
9
  author="David C. Danko",
10
10
  author_email='dcdanko@biotia.io',
11
11
  description=open('README.md').read(),
@@ -1,2 +0,0 @@
1
- FIVE_MB = 5 * (1024 ** 2)
2
- FASTQ_MODULE_NAMES = ['short_read::paired_end', 'short_read::single_end', 'long_read::nanopore']
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
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
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