cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
189 stars 109 forks source link

Allow to read/write files from subfolders in content store #1078

Closed nicolasbisurgi closed 6 months ago

nicolasbisurgi commented 7 months ago

Describe the bug Enhancement: Currently we can only write files to the root folder of the content store. The existing functions do not parse '/' or '\' to reach to subdirectories: "source_files/data/plan_Control.csv" should be transformed to: Contents('Files')/Contents('source_files')/Contents('data')/Contents('plan_Control.csv')/Content?

Version TM1py 2.0.2 TM1 Server Version: 11 and 12 where content store endpoint exists

Additional context Add any other context about the problem here.

MariusWirtz commented 7 months ago

This should be resolved with #1091

@nicolasbisurgi can you confirm that the issue is resolved after you upgrade?

pip uninstall tm1py
pip install  https://github.com/cubewise-code/tm1py/archive/refs/heads/1078-allow-file-io-to-subfolders.zip

Below is an example that works on my end:

from io import BytesIO

from TM1py import TM1Service

tm1params = {
    "base_url": "https://us-east-1.planninganalytics.saas.ibm.com/api/6OGIVKE6499L/v0/tm1/Marius/",
    "user": "apikey",
    "password": "ABCD",
    "async_requests_mode": True
}

with TM1Service(**tm1params) as tm1:
    tm1.files.create(
        file_name="folderA/folderB/file.csv",
        file_content=BytesIO("text".encode('utf-8')))