Skip to content

Commit d33201b

Browse files
authored
Merge pull request #956 from CitrineInformatics/feature/PNE-241-use-team-version-of-tb
PNE-241: Build tables in the team scope
2 parents 885ddb4 + 4c039af commit d33201b

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

src/citrine/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.4.5"
1+
__version__ = "3.4.6"

src/citrine/resources/gemtables.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,13 @@ def initiate_build(self, config: Union[TableConfig, str, UUID], *,
224224
raise ValueError('Version must be specified when building by config uid.')
225225
uid = config
226226
logger.info(f'Submitting table build for config {uid} version {version}...')
227-
path = format_escaped_url('projects/{}/ara-definitions/{}/versions/{}/build',
228-
self.project_id,
229-
uid,
230-
version)
227+
path = format_escaped_url(
228+
"teams/{}/projects/{}/table-configs/{}/versions/{}/build",
229+
self.team_id,
230+
self.project_id,
231+
uid,
232+
version,
233+
)
231234
response = self.session.post_resource(path=path, json={})
232235
submission = JobSubmissionResponse.build(response)
233236
logger.info(

src/citrine/resources/table_config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ def __init__(self, *args, team_id: UUID, project_id: UUID = None, session: Sessi
421421
self.project_id = project_id or args[0]
422422
self.session: Session = session or args[1]
423423
self.team_id = team_id
424+
if self.project_id is None:
425+
raise TypeError("Missing one required argument: project_id.")
426+
if self.session is None:
427+
raise TypeError("Missing one required argument: session.")
424428

425429
def get(self, uid: Union[UUID, str], *, version: Optional[int] = None):
426430
"""Get a table config.
@@ -527,7 +531,7 @@ def default_for_material(
527531
else: # Not per spec, but be forgiving
528532
params['algorithm'] = str(algorithm)
529533
data = self.session.get_resource(
530-
format_escaped_url('projects/{}/table-configs/default', self.project_id),
534+
format_escaped_url('teams/{}/table-configs/default', self.team_id),
531535
params=params,
532536
)
533537
config = TableConfig.build(data['config'])
@@ -548,7 +552,10 @@ def preview(self, *,
548552
List of links to the material runs to use as terminal materials in the preview
549553
550554
"""
551-
path = self._get_path(action="preview")
555+
path = path = format_escaped_url(
556+
"teams/{}/ara-definitions/preview",
557+
self.team_id
558+
)
552559
body = {
553560
"definition": table_config.dump(),
554561
"rows": [x.as_dict() for x in preview_materials]

tests/resources/test_table_config.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,27 @@ def empty_defn() -> TableConfig:
6363
return TableConfig(name="empty", description="empty", datasets=[], rows=[], variables=[], columns=[])
6464

6565

66+
def test_deprecation_of_positional_arguments(session):
67+
with pytest.deprecated_call():
68+
TableConfigCollection(
69+
UUID('6b608f78-e341-422c-8076-35adc8828545'),
70+
session,
71+
team_id=UUID('6b608f78-e341-422c-8076-35adc8828545'),
72+
)
73+
74+
with pytest.raises(TypeError):
75+
TableConfigCollection(
76+
team_id=UUID('6b608f78-e341-422c-8076-35adc8828545'),
77+
session=session
78+
)
79+
80+
with pytest.raises(TypeError):
81+
TableConfigCollection(
82+
team_id=UUID('6b608f78-e341-422c-8076-35adc8828545'),
83+
project_id=UUID('6b608f78-e341-422c-8076-35adc8828545')
84+
)
85+
86+
6687
def test_get_table_config(collection, session):
6788
"""Get table config, with or without version"""
6889

@@ -221,7 +242,7 @@ def test_preview(collection, session):
221242
assert 1 == session.num_calls
222243
expect_call = FakeCall(
223244
method="POST",
224-
path=f"projects/{collection.project_id}/ara-definitions/preview",
245+
path=f"teams/{collection.team_id}/ara-definitions/preview",
225246
json={"definition": empty_defn().dump(), "rows": []}
226247
)
227248
assert session.last_call == expect_call
@@ -257,7 +278,7 @@ def test_default_for_material(collection: TableConfigCollection, session):
257278
assert 1 == session.num_calls
258279
assert session.last_call == FakeCall(
259280
method="GET",
260-
path=f"projects/{collection.project_id}/table-configs/default",
281+
path=f"teams/{collection.team_id}/table-configs/default",
261282
params={
262283
'id': 'my_id',
263284
'scope': CITRINE_SCOPE,
@@ -279,7 +300,7 @@ def test_default_for_material(collection: TableConfigCollection, session):
279300
assert 1 == session.num_calls
280301
assert session.last_call == FakeCall(
281302
method="GET",
282-
path=f"projects/{collection.project_id}/table-configs/default",
303+
path=f"teams/{collection.team_id}/table-configs/default",
283304
params={
284305
'id': 'id',
285306
'scope': 'scope',

0 commit comments

Comments
 (0)