Skip to content

Commit 680855a

Browse files
committed
Adding cloning for shared resources
1 parent c3c7c5b commit 680855a

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
9.6.1 (2023-08-01)
7+
------------------
8+
9+
- Adding shared resources cloning.
10+
611
9.6.0 (2023-07-20)
712
------------------
813

bigml/api_handlers/resourcehandler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,10 @@ def _set_clone_from_args(self, origin, resource_type, args=None,
850850
if args is not None:
851851
create_args.update(args)
852852

853-
create_args.update({"origin": origin_id})
853+
attr = "shared_hash" if origin_id.startswith("shared") else "origin"
854+
if attr == "shared_hash":
855+
origin_id = origin["object"][attr]
856+
create_args.update({attr: origin_id})
854857

855858
return create_args
856859

bigml/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '9.6.0'
1+
__version__ = '9.6.1'

docs/creating_resources.rst

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,8 @@ Existing deepnets can also be cloned:
13601360
.. code-block:: python
13611361
from bigml.api import BigML
13621362
api = BigML()
1363-
deepnets = "deepnets/526fc344035d071ea3031d76"
1364-
cloned_deepnets = api.clone_deepnets(deepnets)
1363+
deepnet = "deepnet/526fc344035d071ea3031d76"
1364+
cloned_deepnet = api.clone_deepnet(deepnet)
13651365
13661366
13671367
Creating PCAs
@@ -1508,3 +1508,45 @@ PCA to compute the projection that corresponds to each input data instance:
15081508
pca, dataset, {
15091509
"name": "my batch pca", "all_fields": True,
15101510
"header": True})
1511+
1512+
Cloning Resources
1513+
~~~~~~~~~~~~~~~~~
1514+
1515+
In the previous sections, you've been able to see that sources,
1516+
datasets and models can be cloned using the corresponding
1517+
``clone_[resource_type]` method.
1518+
1519+
.. code-block:: python
1520+
from bigml.api import BigML
1521+
api = BigML()
1522+
logistic_regression = "logisticregression/526fc344035d071ea3031d76"
1523+
cloned_logistic_regression = api.clone_logistic_regression(
1524+
logistic_regression)
1525+
1526+
Usually, cloning is applied when someone
1527+
shares a resources with us and we need to use it in our account. In that case
1528+
the link to the shared resource contains a shared hash, which is at the end
1529+
of the URL. That shared ID can be used as input to clone it.
1530+
1531+
.. code-block:: python
1532+
from bigml.api import BigML
1533+
api = BigML()
1534+
shared_deepnets = "shared/deepnet/s2KQBFQHMeIrbaTF5uncNsM8HKB"
1535+
cloned_deepnet = api.clone_deepnet(shared_deepnet)
1536+
1537+
Sharing and cloning can be especially useful to useres that belong to
1538+
one ``Organization``. For privacy reasons, the projects created inside the
1539+
``Organization`` are not visible from the private user account environment and
1540+
vice versa. If those users create a resource in their private account and then
1541+
want to share it in a project that belongs to the organization, they can
1542+
create the corresponding secret link and use it to clone it in the
1543+
organization's project. That will, of course, need the connection to be
1544+
pointing to that specific project.
1545+
1546+
.. code-block:: python
1547+
from bigml.api import BigML
1548+
org_project = "project/526fc344035d071ea3031436"
1549+
# Creating a connection to the organization's project
1550+
api = BigML(project=org_project)
1551+
shared_model = "shared/model/s2KQBFQHMeIrbaTF5uncNsM8HKB"
1552+
cloned_model = api.clone_model(model)

0 commit comments

Comments
 (0)