BookmarkSubscribeRSS Feed
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Dear Community!

 

I am looking for a way to %include code from a github repository (several autocall macros). I can do so with a public repository, but what about a private repository? 

 

We have had several discussions here on accessing git repositories directly and reading data from it (both data and code  or just macro code). But all these approaches require a public repository to have the links to the data/code code working (equivalent to the raw file button in github).  In this posting @ChrisHemedinger  has sketched out what I actually want to achive (first code fragment) ... and what I would like to avoid (second code fragment using the gitfn_*).

 

The problem is ... that the link to the raw file in a private repository gets an oauth token appended, but that changes over time. And private access tokens cannot be used in the same fashion (at least by the looks of it). Instead the wise internet suggest the use of a header ("Authentication: token TOKEN") for a similar access problem using curl.  In curl there is a nice option to do this ... but how to do this in SAS?

 

Just another piece of information: I am limited to the use of GitHub Enterprise and non public repositories. It could very well be that I am barking up the wrong tree ... maybe ssl authentication is the way to go. So, to cut it short:

 

Does anybody have any experience with accessing non public github repositories  under SAS and using  %include to source in autocall macros? (and is willing to share his expertise of course 😃)

 

Regards

fja

 

23 REPLIES 23
Reeza
Super User

What version of SAS (Studio/EG/Viya)?

 

Are you looking at connecting to your repository overall or rather just at startup?

 

 

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Hello Reya!

Thank you very much for your reply.

SAS 9.4 EG 8.2, but using %include should be independant of the EG version.

It is just a punctual connect i am looking at just for establishing a connection via filename ... to a single file in a repository or a directory.

The first shall be used for sourcing in a single file ... the latter would be used to set up the autosas option.

Cheers
Fja

Reeza
Super User
Right, if you don't want to connect and create a local repository, it does make it a more complicated process. Especially if doing this for multiple files.
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10
I feared it to be so ... nevertheless from the coding side it is ever so charming: setting up a filename and off you go ...
But you are correct, doing it via a temporary clone is doable ... but then again one needed to ensure that your local copy (clone) is always updated to the latest ...
Reeza
Super User
Yes, but git functions are smart enough to only update files as needed.
Quentin
Super User

@Reeza wrote:
Yes, but git functions are smart enough to only update files as needed.

Good point.  So presumably you could wrap Chris's code from the other thread in an autocall macro.  So user could run %gitinclude(repo=,file=) and it would use SAS git functions to update the local repo, then %include the specified .sas file.  I suppose if you wanted to, the local repo could even be put in the WORK dir.

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Reeza
Super User
If you use work, can use gitclone and then a %include, I would wrap the whole thing in a local macro and call that?
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

NOTE: libgit2.so not found in the system location, trying the extension path.
NOTE: libgit2.so not found in the system location, trying the install path.
ERROR: libgit2.so not found.
ERROR: Unable to load libgit2 module.

Lovely! So I need to check with the admins first ... It might not be a wandering star I was born under ... but it is not a good one by the looks of it. 🙂

Reeza
Super User
Are you on 9.4M6+?
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Current version: 9.04.01M7P080520

i.e. yes. 😀

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Ok, admins say they need a concept for using git and "if and how" git could be integrated with SAS. I read that as "go away". 😃

 

Question:  Does anybody know, if SAS brings its own git (i.e. the shared objects) or does it rely on the OS to provide these? I was under the impression that the first case held true.

Quentin
Super User

@fja wrote:

Ok, admins say they need a concept for using git and "if and how" git could be integrated with SAS. I read that as "go away". 😃

 

Question:  Does anybody know, if SAS brings its own git (i.e. the shared objects) or does it rely on the OS to provide these? I was under the impression that the first case held true.


I *think* you are correct that SAS brings its own git.  Pretty sure you can use EG or Studio to connect to git, and also use the git functions in SAS code, without ever installing git on the OS.

 

But in my limited experience, I think it would be hard to use git without having it also available on the OS so you can use non-SAS git interfaces/clients.  We store our SAS code on a linux server, and have central git repos on a Windows server somewhere.  I tried playing with git, but the admins weren't interested in investing time to get the authentication working between our linux SAS box and the windows box with the git repo.  I don't think I could have done it from within SAS even if I had tried.  I have played with some ugly workarounds running git locally on windows, so I can connect to the central git repos from windows, and accessing the linux files via samba....

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

@Quentin wrote:
[...]but the admins weren't interested in investing time to get the authentication working between our linux SAS box and the windows box with the git repo.  [...]

Oh this sounds ever so familiar! 😐

Thank's for the reply!

AhmedAl_Attar
Rhodochrosite | Level 12

Hi @fja 

I have a feeling your System Admins would need to install git on your SAS server before you could SAS's git functions  (gitfn_*)

 

Hope this helps

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 23 replies
  • 2219 views
  • 16 likes
  • 5 in conversation