Skip to content

Commit 66c334b

Browse files
committed
Allow sharing datasets via a project.
Publishing, unpublishing, and pulling in project-based datasets should still work as before, albeit with a deprecation warning.
1 parent 619e003 commit 66c334b

File tree

3 files changed

+53
-26
lines changed

3 files changed

+53
-26
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.0"
1+
__version__ = "3.4.1"

src/citrine/resources/project.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,15 @@ def publish(self, *, resource: Resource):
351351
resource_access = resource.access_control_dict()
352352
resource_type = resource_access["type"]
353353
if resource_type == ResourceTypeEnum.DATASET:
354-
warn("Datasets are now auotmatically accessible to all projects in a given team, so "
355-
"publishing is no longer necessary.",
354+
warn("Newly created datasets belong to a team, making this is unncessary. If it was "
355+
"created before 3.4.0, publish will work as before. Calling publish on datasets "
356+
"will be disabled in 4.0.0, at which time all datasets will be automatically "
357+
"published.",
356358
DeprecationWarning)
357-
else:
358-
self.session.checked_post(
359-
f"{self._path()}/published-resources/{resource_type}/batch-publish",
360-
version='v3',
361-
json={'ids': [resource_access["id"]]})
359+
self.session.checked_post(
360+
f"{self._path()}/published-resources/{resource_type}/batch-publish",
361+
version='v3',
362+
json={'ids': [resource_access["id"]]})
362363
return True
363364

364365
def un_publish(self, *, resource: Resource):
@@ -379,14 +380,15 @@ def un_publish(self, *, resource: Resource):
379380
resource_access = resource.access_control_dict()
380381
resource_type = resource_access["type"]
381382
if resource_type == ResourceTypeEnum.DATASET:
382-
warn("Datasets are now auotmatically accessible to all projects in a given team, so "
383-
"unpublishing doesn't do anything.",
383+
warn("Newly created datasets belong to a team, making un_publish a no-op. If it was "
384+
"created before 3.4.0, un_publish will work as before. Calling un_publish on "
385+
"datasets will be disabled in 4.0.0, at which time all datasets will be "
386+
"automatically published.",
384387
DeprecationWarning)
385-
else:
386-
self.session.checked_post(
387-
f"{self._path()}/published-resources/{resource_type}/batch-un-publish",
388-
version='v3',
389-
json={'ids': [resource_access["id"]]})
388+
self.session.checked_post(
389+
f"{self._path()}/published-resources/{resource_type}/batch-un-publish",
390+
version='v3',
391+
json={'ids': [resource_access["id"]]})
390392
return True
391393

392394
def pull_in_resource(self, *, resource: Resource):
@@ -407,15 +409,16 @@ def pull_in_resource(self, *, resource: Resource):
407409
resource_access = resource.access_control_dict()
408410
resource_type = resource_access["type"]
409411
if resource_type == ResourceTypeEnum.DATASET:
410-
warn("Datasets are now auotmatically accessible to all projects in a given team, so "
411-
"pulling them in is unnecessary.",
412+
warn("Newly created datasets belong to a team, making pull_in_resource a no-op. If it "
413+
"was created before 3.4.0, pull_in_resource will work as before. Calling "
414+
"pull_in_resource on datasets will be disabled in 4.0.0, at which time all "
415+
"datasets will be automatically published.",
412416
DeprecationWarning)
413-
else:
414-
base_url = f'/teams/{self.team_id}{self._path()}'
415-
self.session.checked_post(
416-
f'{base_url}/outside-resources/{resource_type}/batch-pull-in',
417-
version='v3',
418-
json={'ids': [resource_access["id"]]})
417+
base_url = f'/teams/{self.team_id}{self._path()}'
418+
self.session.checked_post(
419+
f'{base_url}/outside-resources/{resource_type}/batch-pull-in',
420+
version='v3',
421+
json={'ids': [resource_access["id"]]})
419422
return True
420423

421424
def owned_dataset_ids(self) -> List[str]:

tests/resources/test_project.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ def test_publish_resource_deprecated(project, datasets, session):
9696
with pytest.deprecated_call():
9797
assert project.publish(resource=dataset)
9898

99-
assert 0 == session.num_calls
99+
assert 1 == session.num_calls
100+
expected_call = FakeCall(
101+
method='POST',
102+
path=f'/projects/{project.uid}/published-resources/DATASET/batch-publish',
103+
json={
104+
'ids': [str(dataset.uid)]
105+
}
106+
)
107+
assert expected_call == session.last_call
100108

101109

102110
def test_pull_in_resource(project, datasets, session):
@@ -124,7 +132,15 @@ def test_pull_in_resource_deprecated(project, datasets, session):
124132
with pytest.deprecated_call():
125133
assert project.pull_in_resource(resource=dataset)
126134

127-
assert 0 == session.num_calls
135+
assert 1 == session.num_calls
136+
expected_call = FakeCall(
137+
method='POST',
138+
path=f'/teams/{project.team_id}/projects/{project.uid}/outside-resources/DATASET/batch-pull-in',
139+
json={
140+
'ids': [str(dataset.uid)]
141+
}
142+
)
143+
assert expected_call == session.last_call
128144

129145

130146
def test_un_publish_resource(project, datasets, session):
@@ -152,7 +168,15 @@ def test_un_publish_resource_deprecated(project, datasets, session):
152168
with pytest.deprecated_call():
153169
assert project.un_publish(resource=dataset)
154170

155-
assert 0 == session.num_calls
171+
assert 1 == session.num_calls
172+
expected_call = FakeCall(
173+
method='POST',
174+
path=f'/projects/{project.uid}/published-resources/DATASET/batch-un-publish',
175+
json={
176+
'ids': [str(dataset.uid)]
177+
}
178+
)
179+
assert expected_call == session.last_call
156180

157181

158182
def test_datasets_get_project_id(project):

0 commit comments

Comments
 (0)