sassoftware / sas-container-recipes

A collection of recipes and other resources for building containers that include SAS Viya software.
https://www.sas.com
Apache License 2.0
89 stars 42 forks source link

Absolute path detected, but authentication failed. #4

Closed neallee2012 closed 5 years ago

neallee2012 commented 5 years ago

Hi @hornpolish,

When I try to load image from an absolute path, I keep getting following message: ERROR: Absolute path detected, but authentication failed. Please use a caslib, or gain the ability to assume an administrator role for using absolute paths. ERROR: The action stopped due to errors.

And in CAS log, here is a corresponding message: 2018-09-05T09:28:22,234 INFO [00000007] cas local 14662 sasdemo 13 [tkcasaimp.c:6055] - -- 'image.loadimages' FAILED. Absolute path detected, but authentication failed. Please use a caslib, or gain the ability to assume an administrator role for using absolute paths.

Here is the code I run:

%matplotlib inline
import swat as sw
from IPython.display import Image, display

# Start CAS session
s = sw.CAS('localhost', 5570)
s.loadactionset('image')

path='/tmp/IMG'
s.image.loadimages(casout=dict(name='train', blocksize='128',replace=True), recurse=True, 
decode=True, distribution="RANDOM", labelLevels=-2, path=path)

You can just run it, and message will be shown. (it is shown before checking if this folder is exist) Could you please help to point out the cause?

Thanks, Neal

blruss commented 5 years ago

Neal,

It looks like either authentication failed when connecting to your cas server failed for the user sasdemo or the administrator could not be assumed if granted the permissions. The sasdemo user in the container deployment should be automatically assumed by default unless customized.

Did you retrieve the generated password for the sasdemo user ? Did you change it?

docker logs sas-viya-programming 2>&1 | grep Password=

Are you able to connect to the cas server using the following syntax successfully as the sasdemo user?

connect = swat.CAS('localhost', 5570, 'sasdemo', 'mypassword')

I would also recommend seeing the SAS Viya 3.4 for Containers: Deployment Guide in chapter 2 (page 10) for User and Group requirements. Specifically the section titled CAS Administrator Account Requirements will be of interest to you if you haven't reviewed this yet.

blruss commented 5 years ago

Also check to see if your user has ~/.authinfo file stored with the username and password. Verify the contents to make sure the file is correct.

cat ~/.authinfo

hornpolish commented 5 years ago

The security model in CAS revolves around securing the caslib, and then entities under that inherit the security. So to achieve the loadimages() you want, you'd need to do something like

` %matplotlib inline import swat as sw from IPython.display import Image, display

Start CAS session

s = sw.CAS('localhost', 5570)

s.addcaslib(name=imglib, path='/tmp/IMG', subdirectories=True, datasource='path')

img = s.CASTable(name='img, blocksize='128', replace=True)

r = s.image.loadimages(path = '.', caslib=imglib, recurse=True, casout=img) `

let us know if that works for you

neallee2012 commented 5 years ago

@hornpolish, thanks for the tip! Here is the working python code.

Start a CAS session

%matplotlib inline
import swat as sw
from IPython.display import Image, display

# Start CAS session
s = sw.CAS('localhost', 5570)
s.loadactionset('image')

Define a caslib

# assume that image files are located at
# /home/user01/image
s.table.addcaslib(lib='data',
  datasource={'srcType' : 'path'},
  path="/home/user01",
  subdirectories=True)

Load images by using paths relative to the caslib

s.image.loadImages(path='image/',
   caslib = 'data',
   casout=dict(name='train', blocksize='128',replace=True),
   recurse=True, 
   decode=True, labelLevels=-2)

Show images info

s.image.fetchImages(
    table = 'train'
)
hornpolish commented 5 years ago

sweet! thanks for the working code - hopefully that will help the next person.

cj13579 commented 2 years ago

sweet! thanks for the working code - hopefully that will help the next person.

As expected, this did help someone out! Thanks for posting @neallee2012