Issue with calling "RUN LOADING JOB"

I created LOADING JOBs like this

#CREATE LOADING JOBs
results = conn.gsql('''
USE GRAPH movie_graph
BEGIN
DROP JOB py_job_movies
CREATE LOADING JOB py_job_movies FOR GRAPH movie_graph {
      DEFINE FILENAME MyDataSource;
      LOAD MyDataSource TO VERTEX movie VALUES($0, $1, $2) USING SEPARATOR=";", HEADER="true", EOL="\n", QUOTE="double";
    }
END''')
print(results)

results = conn.gsql('''
USE GRAPH movie_graph
BEGIN
DROP JOB py_job_persons
CREATE LOADING JOB py_job_persons FOR GRAPH movie_graph {
      DEFINE FILENAME MyDataSource;
      LOAD MyDataSource TO VERTEX person VALUES($0, $1) USING SEPARATOR=";", HEADER="true", EOL="\n", QUOTE="double";
    }
END''')
print(results)


results = conn.gsql('''
USE GRAPH movie_graph
BEGIN
DROP JOB py_job_acted_in
CREATE LOADING JOB py_job_acted_in FOR GRAPH movie_graph {
      DEFINE FILENAME MyDataSource;
      LOAD MyDataSource TO EDGE ACTED_IN VALUES($0, $1) USING SEPARATOR=";", HEADER="true", EOL="\n", QUOTE="double";
    }
END''')
print(results)

print(conn.graphname)
conn.gsql("USE GRAPH movie_graph")
results = conn.gsql('''USE GRAPH movie_graph
    SHOW JOB *''')
print(results)

print(conn.gsql("LS"))

LS output shows that the jobs are successfully created

Using graph 'movie_graph'
  - CREATE LOADING JOB py_job_movies FOR GRAPH movie_graph {
      DEFINE FILENAME MyDataSource;
      LOAD MyDataSource TO VERTEX movie VALUES($0, $1, $2) USING SEPARATOR=";", HEADER="true", EOL="
", QUOTE="double";
    }

  - CREATE LOADING JOB py_job_persons FOR GRAPH movie_graph {
      DEFINE FILENAME MyDataSource;
      LOAD MyDataSource TO VERTEX person VALUES($0, $1) USING SEPARATOR=";", HEADER="true", EOL="
", QUOTE="double";
    }

  - CREATE LOADING JOB py_job_acted_in FOR GRAPH movie_graph {
      DEFINE FILENAME MyDataSource;
      LOAD MyDataSource TO EDGE ACTED_IN VALUES($0, $1) USING SEPARATOR=";", HEADER="true", EOL="
", QUOTE="double";
    }

I tried uploading a file from relative path to TigerGraph cloud

dataSource = "/content/knowledge_graph_using_tigergraph/data/movies.csv"
results = conn.gsql('''
USE GRAPH movie_graph
RUN LOADING JOB py_job_movies USING MyDataSource="'+dataSource+'"
''')
print(results)

and got error

---------------------------------------------------------------------------
TigerGraphException                       Traceback (most recent call last)
<ipython-input-54-b65000c1c30d> in <cell line: 2>()
      1 dataSource = "/content/knowledge_graph_using_tigergraph/data/movies.csv"
----> 2 results = conn.gsql('''
      3 USE GRAPH movie_graph
      4 RUN LOADING JOB py_job_movies USING MyDataSource="'+dataSource+'"
      5 ''')

1 frames
/usr/local/lib/python3.10/dist-packages/pyTigerGraph/pyTigerGraphGSQL.py in check_error(query, resp)
     60             if "RUN LOADING JOB" in query.upper():
     61                 if "LOAD SUCCESSFUL to TigerGraph" not in resp:
---> 62                     raise TigerGraphException(resp)
     63 
     64         def clean_res(resp: list) -> str:

TigerGraphException: Using graph 'movie_graph'
Semantic Check Fails: TigerGraph sensitive directory '/home/tigergraph/tigergraph/app' is not allowed in path '/home/tigergraph/tigergraph/app/3.10.0/dev/gdk/gsql/'+dataSource+''. Please use another path.

I also tried calling runLoadingJobWithFile

#RUN LOADING JOBs
f_movies =  "/content/knowledge_graph_using_tigergraph/data/movies.csv"
f_persons = "/content/knowledge_graph_using_tigergraph/data/actors.csv"
f_acted_in = "/content/knowledge_graph_using_tigergraph/data/acted_in.csv"

res = conn.runLoadingJobWithFile(filePath=f_movies, fileTag='file_movies', jobName='py_job_movies', sep=";")
print(json.dumps(res, indent=2))
res = conn.runLoadingJobWithFile(filePath=f_persons, fileTag='file_persons', jobName='py_job_persons', sep=";")
print(json.dumps(res, indent=2))
res = conn.runLoadingJobWithFile(filePath=f_acted_in, fileTag='file_acted_in', jobName='py_job_acted_in', sep=";")
print(json.dumps(res, indent=2))

and got exception

TigerGraphException                       Traceback (most recent call last)
<ipython-input-56-35e3ad290ad6> in <cell line: 5>()
      3 f_acted_in="/content/knowledge_graph_using_tigergraph/data/acted_in.csv"
      4 
----> 5 res = conn.runLoadingJobWithFile(filePath=f_movies, fileTag='file_movies', jobName='py_job_movies', sep=";")
      6 print(json.dumps(res, indent=2))
      7 res = conn.runLoadingJobWithFile(filePath=f_persons, fileTag='file_persons', jobName='py_job_persons', sep=";")

3 frames
/usr/local/lib/python3.10/dist-packages/pyTigerGraph/pyTigerGraphBase.py in _errorCheck(self, res)
    220         if "error" in res and res["error"] and res["error"] != "false":
    221             # Endpoint might return string "false" rather than Boolean false
--> 222             raise TigerGraphException(res["message"], (res["code"] if "code" in res else None))
    223 
    224     def _req(self, method: str, url: str, authMode: str = "token", headers: dict = None,

TigerGraphException: ('Exception in OnFinish: GetResult index out of range, index: 0 | response_datas_.size()0', 'REST-10005')

Hi @arshdeep_kaur ,

If you use GSQL loading job, like here:

USE GRAPH movie_graph
RUN LOADING JOB py_job_movies USING MyDataSource="'+dataSource+'"

The dataSource file path cannot be the local files that you have on your computer.

If you use pyTigerGraph runLoadingJobWithFile, I think your file paths should be something like this, as /content/knowledge_graph_using_tigergraph/data/movies.csv is an absolute path:
content/knowledge_graph_using_tigergraph/data/movies.csv

  • if that still doesn’t work, I’d suggest checking out the logs in the Admin Portal and see the error message on TigerGraph’s side

I hope this helps! Please let us know if there are any further questions.

Best,
Supawish Limprasert (Jim)