Error prolog procedure line 0 unable to open data source

Error occurs when running a TI process that imports a csv file.Preview displays the correct data.

Troubleshooting

Problem

Error occurs when running a TI process that imports a csv file.
Preview displays the correct data.

Symptom

Error: Prolog procedure line (0): Unable to open data source «\datasprodtm1DataLoadfilestest.csv»

Cause

The path specified for Data Source Name on Server is incorrect

Diagnosing The Problem

NOTE:
The values for «Data Source Name» and «Data source Name on Server» should be different.

Data Source Name — this is the path used by the architect client — the full path is required to where the csv exists. (click the browse and select the csv file.
Data Source Name on Server — this is the path used by the TM1 server — it should be «relative»to the TM1 data directory. (the folder where the tm1 objects are in)

In addition, it is important to understand that TM1 has only access to files which exist under or relative to the TM1 data directory.  

If one uses relative paths, then the relative path needs to be relative to the TM1 data directory. But other than that, the files can be anywhere in the \data directory as long as the path name for ‘data source name on server’ is specified using via s:… or relative to the data directory. 

Whether or not the tm1 server only has access to it’s own data directory is off by default, and can be turned on via a support ticket:
Controlling TM1 Server access to data in shared folders:
https://www.ibm.com/support/knowledgecenter/en/SSD29G_2.0.0/com.ibm.swg.ba.cognos.tm1_cloud_mg.2.0.0.doc/c_tm1_cloud_controlling_access.html

Resolving The Problem

1. Confirm the directory where all the tm1 objects? 
This is the starting point.

STEPS:
The following steps are assuming the objects are in the data directory under TM1.

1. One would first create a folder named «loadfiles» under S:prodtm1data 
Thus, any files you need to load are all in one folder under the data directory.
NOTE: This folder can be named anything, it is used to simplify the setup.

2. The paths would be as follows:
  Data Source Name:  \datasprodtm1dataloadfilesxxx.csv  (if the Preview displays data then this path is correct, no changes required)

and

  Data Source Name on Server:     .loadfilestest.csv   
(here one removes all directories up to where the objects exist…ie: data) or   take the . out and just be:    loadfilesxxx.csv                                            
 Note there is a dot and a backslash for the second path.  (the dot slash relates to the data directory where all the objects are stored)

3. Make sure to SAVE each time you make a change to the path or the error will continue as it is picking up the last saved change

NOTE:
If the preview works and displays data, this means thee first box in TI process is fine and no changes required, change the second box path only.

[{«Product»:{«code»:»SSD29G»,»label»:»IBM Planning Analytics»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Component»:»Planning Analytics»,»Platform»:[{«code»:»PF025″,»label»:»Platform Independent»}],»Version»:»Version Independent»,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}},{«Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Product»:{«code»:»SSD29G»,»label»:»IBM Planning Analytics»},»Component»:»»,»Platform»:[{«code»:»PF033″,»label»:»Windows»}],»Version»:»All Versions»,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]

Product:

IBM Cognos Tm1 10.2.2 fix pack 4

Issue:

Try to create a subset and get an error when run the TM1 TI process.

Process will set READ on selected DIMENSIONS for a defined AD group.

Error message:

Error: Prolog procedure line (67): Unable to register subset

Possible solution:

Missing last parameter in function, which should add all dimensions that start with S2 in name to subset.

SubsetCreatebyMDX ( sSubset , ‘{TM1FILTERBYPATTERN( {TM1SubsetALL( [ ‘| sDim |’ ]  )},   “S2.*” )}’ ,1);

Was missing last 1.

The function add the values that should be part of the subset

SubsetElementInsert(DimName, SubName, ElName, Position);

The variables are declared before with

sDim=’}Dimensions’;

sName = ‘$.’| GetProcessName();

sSubset=sName|sDim;

More info ( full prolog ):

#****Begin: Generated Statements***

#****End: Generated Statements****

sSecurityCube =  ‘}DimensionSecurity’;

#———————————————————————————–

# to add ” in the string you need a variable

#  more info: http://www.robelle.com/smugbook/ascii.html

#———————————————————————————–

q=char(34);

#—————————————————————————————–

# create the view as a static public view: CUBESEC

#—————————————————————————————

pFromCube = sSecurityCube;

SourceView= pFromCube | ‘CUBESEC’;

#——————————————————————

#    Create views

#———————————————————————

if(ViewExists(pFromCube, SourceView)=1);

viewDestroy(pFromCube, SourceView);

endif;

viewCreate(pFromCube, SourceView);

#——————————————————————

#    Define variables

#———————————————————————

sBIgroup = ‘CAMID(“:LDAP:Cognos_FAP_Users”)’;

sSecutiryAction = ‘READ’;

sDim=’}Dimensions’;

sName = ‘$.’| GetProcessName();

sSubset=sName|sDim;

#———————————————————————————–

# If subset exist then it is destroyed before created

#———————————————————————————-

if(subsetExists(sDim,sSubset)= 1);

subsetDeleteAllElements(sDim, sSubset);

else;

subsetCreate(sDim, sSubset);

endif;

#——————————————————————————————————————

# add the values that should be part of the subset

# SubsetElementInsert(DimName, SubName, ElName, Position);

# should be all dim that start with S2, so a MDX look like this

#   {TM1FILTERBYPATTERN( {TM1SubsetBasis()}, “S2.*”)}

#———————————————————————————————–

SubsetCreatebyMDX ( sSubset , ‘{TM1FILTERBYPATTERN( {TM1SubsetALL( [ ‘| sDim |’ ]  )},   “S2.*” )}’ ,1);

#——————————————————

# add subset to view

#——————————————————-

ViewSubsetAssign(pFromCube, SourceView, sDim, sSubset);

#——————————————————————————-

#       Set source   – we only use subset in dim

#——————————————————————————–

DataSourceType=’SUBSET’;

DataSourceNameForServer=  sDim;

DatasourceDimensionSubset=   sSubSet  ;

#————————————————————————————————–

i=1;

G2 = SubsetGetSize( sDim, sSubSet);

while (i <= G2);

G1= ( SubsetGetElementName  ( sDim, sSubSet, I));

cellputs  (  sSecutiryAction , sSecurityCube, G1  , sBIgroup );

i=i+1;

end;

#—————————————————————————–

# end of code

#—————————————————————————–

Epilog should have some clean up code like this:

if (ViewExists(pFromCube, SourceView)=1);

viewDestroy(pFromCube, SourceView);

endif;

#———————————————

# destroy temp subset

#———————————————

sDim=’}Cubes’;

sName = ‘$.’| GetProcessName();

sSubset=sName|sDim;

subsetDestroy(sDim, sSubset);

Hi @EricSteingrabe could you share a code snippet to better understand exactly how you are using ‘execute_process_with_return’?

for example

status = tm1.processes.execute_with_return(process_name='Cub_Load_GL_TB_Master',
                                           pParameter1='P1Value',
                                           pParameter2='P2Value')
logger.info(f'TB Master complete with status: {status[1]}')

with execute_proces_with_return method, you have to explicitly create a Process object and add all the required parameters to it.

  1. Is your usecase to create a new Process in python and execute it?
    or
  2. Execute an existing TI process in your instance?

For the former you use this as an example:

process = Process(name="Test_Process")
process.add_parameter(name="P0", prompt="logoutput message", value="Here you go")
process.prolog_procedure = "LOGOUTPUT('WARN', P0 ) ;"
success, status, _ = tm1.processes.execute_process_with_return(process=process)
print("Process {}".format(status))

For the latter, follow @jrobinsonAG‘s example.

Ok, I give more detail about my issue. We are loading a csv file via python and create the TI process using python as part of the execution but prior to the script I’m posting below. The TI process named is «_tmp_Upload» and it has 1 parameter called pFile which contains the filepath of the file to be loaded into the system.

We currently run the below function and this is executing successfully:

def create_run_upload_ti(connection, cube_name, file, data_type):

    ti_name = '_tmp_Upload'
    run_ti_params = {'pFile': file}

    create_upload_ti(ti_name=ti_name, cube_name=cube_name, connection=connection, data_type=data_type)
    ret_val_upload = connection.processes.execute_with_return(ti_name, **run_ti_params)

    return ret_val_upload

Please note that the create_upload_ti function simply creates a TI process in the TM1 server. We had some locking issues within TM1 with the creation and deletion of the process and therefore wanted to change this to use an unbound process. Therefore I changed the script to this:

def create_run_upload_ti(connection, cube_name, file, data_type):

    ti_name = '_tmp_Upload'
    run_ti_params = {'pFile': file}

    py_ti = create_upload_process(ti_name=ti_name, cube_name=cube_name, connection=connection, data_type=data_type)
    ret_val_upload = connection.processes.execute_process_with_return(process=py_ti, **run_ti_params)

    return ret_val_upload

Running the above scripts gives me the following error message «Error: Prolog procedure line (0): Unable to open data source «d:data directory».» This is the path to the data directory of the TM1 server and you receive this error message when you don’t give a path in the parameter and it assumes the data directory.

Subsequently I checked the ProcessServices in tm1py and I think the function processes.execute_with_return passes parameters over to the process and the function processes.execute_process_with_return does not. Specifically I think this code is missing in the processes.execute_process_with_return function.

        parameters = dict()
        if kwargs:
            parameters = {"Parameters": []}
            for parameter_name, parameter_value in kwargs.items():
                parameters["Parameters"].append({"Name": parameter_name, "Value": parameter_value})

Below is the whole code from the ProcessServer.py as a reference:

  def execute_process_with_return(self, process: Process, **kwargs) -> Tuple[bool, str, str]:
        """
        Run unbound TI code directly
        :param process: a TI Process Object
        :return: success (boolean), status (String), error_log_file (String)
        """
        url = "/api/v1/ExecuteProcessWithReturn?$expand=*"

        payload = json.loads("{"Process":" + process.body + "}")

        response = self._rest.POST(
            url=url,
            data=json.dumps(payload, ensure_ascii=False),
            **kwargs)

        execution_summary = response.json()

        success = execution_summary["ProcessExecuteStatusCode"] == "CompletedSuccessfully"
        status = execution_summary["ProcessExecuteStatusCode"]
        error_log_file = None if execution_summary["ErrorLogFile"] is None else execution_summary["ErrorLogFile"][
            "Filename"]
        return success, status, error_log_file

    def execute_with_return(self, process_name: str, timeout: float = None, **kwargs) -> Tuple[bool, str, str]:
        """ Ask TM1 Server to execute a process.
        pass process parameters as keyword arguments to this function. E.g:

        self.tm1.processes.execute_with_return(
            process_name="Bedrock.Server.Wait",
            pWaitSec=2)

        :param process_name: name of the TI process
        :param timeout: Number of seconds that the client will wait to receive the first byte.
        :param kwargs: dictionary of process parameters and values
        :return: success (boolean), status (String), error_log_file (String)
        """
        url = format_url("/api/v1/Processes('{}')/tm1.ExecuteWithReturn?$expand=*", process_name)
        parameters = dict()
        if kwargs:
            parameters = {"Parameters": []}
            for parameter_name, parameter_value in kwargs.items():
                parameters["Parameters"].append({"Name": parameter_name, "Value": parameter_value})

        response = self._rest.POST(
            url=url,
            data=json.dumps(parameters, ensure_ascii=False),
            timeout=timeout,
            **kwargs)
        execution_summary = response.json()
        success = execution_summary["ProcessExecuteStatusCode"] == "CompletedSuccessfully"
        status = execution_summary["ProcessExecuteStatusCode"]
        error_log_file = None if execution_summary["ErrorLogFile"] is None else execution_summary["ErrorLogFile"][
            "Filename"]
        return success, status, error_log_file

Again this is my suspicion that this is missing.

As I mentioned earlier in my comment, you have to add the parameter to the Process object that you are creating.

Try this:

def create_run_upload_ti(connection, cube_name, file, data_type):
    ti_name = '_tmp_Upload'

    py_ti = create_upload_process(ti_name=ti_name, cube_name=cube_name, connection=connection, data_type=data_type)
    py_ti.add.add_parameter(name='pFile', prompt='Path to the csv file', value=file)
    ret_val_upload = connection.processes.execute_process_with_return(process=py_ti)

    return ret_val_upload

@rkvinoth, @EricSteingrabe
I think you have to call the remove_parameter first before you can add it. I assume the pFileparameter already exists.
Maybe try this:

from TM1py import Process

def create_run_upload_ti(connection, cube_name, file, data_type):
    ti_name = '_tmp_Upload'

    py_ti: Process = create_upload_process(ti_name=ti_name, cube_name=cube_name, connection=connection, data_type=data_type)
    py_ti.remove_parameter(name='pFile')
    py_ti.add_parameter(name='pFile', prompt='Path to the csv file', value=file)
    ret_val_upload = connection.processes.execute_process_with_return(process=py_ti)

    return ret_val_upload

But considering your use case @EricSteingrabe I think it’s a fair point.
For your situation, it would be convenient to execute unbound processes with parameters.

We should look into supporting parameters on unbound processes

Agreed, that would be nice for parallel processing as well.

@rkvinoth @MariusWirtz — I’ve tested both of your solutions and can confirm that @MariusWirtz solution works. You’ll need to remove the parameter first (as it exists in the process definition) and then add it again.

Thanks all!

grafrh

0 / 0 / 0

Регистрация: 11.06.2012

Сообщений: 3

1

Ошибка при каждой компиляции

11.06.2012, 22:19. Показов 1887. Ответов 5

Метки нет (Все метки)


Заранее извиняюсь за банальный вопрос, но только сегодня открыл мануал по Prolog, а FAQ на форуме я не нашёл.
Суть в том что я пишу код вида

Prolog
1
2
parent(bob, stan).
?-parent(bob,stan).

При компиляции Visual Prolog выдаёт ошибку. И что характерно, это всегда ошибка в первой строке, первой букве. В чём проблема?
Может быть я чего нибудь не дописал? Не там написал или ещё чего? Большая просьба, если меня куда то и посылать, то в сторону годного мануала по Visual Prolog 7.3. Опыт в программировании почти нулевой. Заранее спасибо.

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Грымзик

2505 / 1479 / 37

Регистрация: 14.09.2009

Сообщений: 2,740

11.06.2012, 23:50

2

В визуал 7.3 другой синтаксис. Там будет как-то так

Prolog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
implement main
    open core, console
 
constants
    className = "main".
    classVersion = "".
 
class facts
    parent:(string,string).
    
class predicates
    is_parent:(string,string) procedure(i,i).
    
clauses
    classInfo(className, classVersion).
    
    parent("bob","stan").
   
    is_parent(A,B):-parent(A,B),!,write(A," is a parent of ",B,"n").
    is_parent(A,B):-write(A," is not a parent of ",B,"n").
    
    run():-
        console::init(),
        is_parent("bob","stan"),
        programControl::sleep(3000),
        succeed().
end implement main
 
goal
    mainExe::run(main::run).



1



0 / 0 / 0

Регистрация: 11.06.2012

Сообщений: 3

12.06.2012, 14:29

 [ТС]

3

Грымзик, спасибо, всё становится яснее.
Сейчас читаю официальный мануал по VIP и пытаюсь вкурить что и куда.
Ещё вопрос. А как будет выглядеть та же задача на SWI-Prolog?



0



2505 / 1479 / 37

Регистрация: 14.09.2009

Сообщений: 2,740

12.06.2012, 14:43

4

Как Вы и написали) Точнее код просто parent(bob, stan), а ?-parent(bob,stan) вызывается в командной строке.



1



grafrh

0 / 0 / 0

Регистрация: 11.06.2012

Сообщений: 3

12.06.2012, 17:16

 [ТС]

5

Грымзик, Выглядит намного проще )
Но при вводе

Prolog
1
parent(bob,stan).

выдаёт следующую ошибку ERROR: toplevel: Undefined procedure: parent/2 (DWIM could not correct goal)
Конечно я уже начал курить хелп, но думаю совет мне не помешает.



0



2505 / 1479 / 37

Регистрация: 14.09.2009

Сообщений: 2,740

12.06.2012, 17:20

6

Вы не скомпили файл.



1



Понравилась статья? Поделить с друзьями:
  • Error reading influxdb status code 401
  • Error reading imagelist bitmap failed to read imagelist data from stream
  • Error reading from tunnel http socket
  • Error project zomboid снизу справа
  • Error reading from source device