LEAF 3.9 Python service

Morning LEAF Team,
I am fascinated by this new Python data service. This morning I generated one with yeoman to take a look. After installing and configuring Poetry things were looking great, but Skaffold complains

depends on leidos-leaf (3.9.2) which doesn’t match any versions, version solving failed.

Which appears to be because of this:

Authorization error accessing https://repo.leidos-leaf.com/repository/leidos-python/simple/leidos-leaf/

However, when I browse to mentioned repository there doesn’t appear to be a leidos-python folder at all.

My current gradle.properties has:

leafMavenUrl=https://repo.leidos-leaf.com/repository/maven-group/

And the actual error in context:

Am I missing something in my gradle configuration or can someone confirm what my leafMavenUrl should be?

Cool service guys!
sg

2 Likes

Good morning, Stephen!

The README for generated Python Functional Services includes a section outlining how to set up LEAF credentials to work with Poetry. Gradle is used for Java services, but not for our generated Python services. You will need to follow the steps under the README’s LEAF Credentials Setup section to get authentication working.

Give a shout if you are still having issues after trying that out!

Thanks,
Trey Hefner

2 Likes

Setup the ~/.config/pypoetry folder then created the auth.toml. Lastly, executed

poetry config http-basic.leaf <NEXUS_USERNAME>

unfortunately, same error.

Hi Steve,

We’re glad that you’re an excited early adopter of the new Python functional service!

There is indeed a private PyPI repository on the LEAF Nexus instance:

If you can’t see the leidos-python repo on Nexus when you browse it manually, perhaps there’s some credential issue going on? You should verify that you can browse to it with your credentials first (the direct link above likely won’t work until after you’ve authenticated in your browser with Nexus).

It can unfortunately be a little tricky using private repositories with Python tooling like pip and poetry.

Using pip manually or by specifying the extraIndex URL in requirements.txt, you may embed credentials in the URL in the HTTP basic auth format. But note that this means any special characters in your username or password must be URL-encoded, eg. the @ sign in your leidos email address must be encoded as %40.

This literal syntax will populate the values from environment variables $NEXUS_USER and $NEXUS_PASSWORD:

# contents of requirements.txt
--index-url https://${NEXUS_USER}:${NEXUS_PASSWORD}@repo.leidos-leaf.com/repository/leidos-python/simple
--extra-index-url https://pypi.org/simple
leidos-leaf == 3.9.2

I apologize that I don’t know much about Poetry, but I believe - on macOS at least - it will use the system keyring for credentials, and you may first need to configure it with these commands:

poetry config repositories.leaf "https://repo.leidos-leaf.com/repository/leidos-python/simple"
poetry config http-basic.leaf <NEXUS_USERNAME>

I believe it may also require you to configure the file ~/.config/pypoetry/auth.toml, with:

[http-basic]
[http-basic.leaf]
password = "<NEXUS_PASSWORD>"
username = "<NEXUS_USERNAME>"

I might humbly suggest trying with good old fashioned pip, and once you’re able to pull the package down that way, then try with poetry?

We welcome any feedback you can provide to help smooth out the process of adopting this new Python service!

  • DR
1 Like

I can login to nexus, but clicking your URI gives me

Screenshot 2023-01-20 at 12.12.10 PM

I confirmed I was logged in. Maybe it’s too private? :slight_smile:

Thank you David,
The updated permissions to the nexus repo. seem to be resolved. I am now able to run

poetry install

and

skaffold run --cache-artifacts=false

and see the service deployed in the default namespace.

Thank you again!

1 Like