Best practice to package a Python project with cli - pip

I wrote a small app returning routes with my public transport.
I'd like to package the app and use it via cli like: $ app_name start destination which is than handled by the app etc.
I've used the entry_points option in setup.py by defining an interface file, which is referenced when running the above code from command line.
However, I do not know if that's a best practice to accomplish that (as I have not found it on python.org.
So: What is a best practice to provide a cli?
An example I've seen:
with pytube you can do
$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --itag=22
[EDIT:] thanks for the comments so far; they hint me to rephrase my question

Related

Kubernetes undefined noderesources.preFilterState

I am rewriting the logic of Kubernetes' NodeResourcesFit plugin, I want to use preFilterState like https://github.com/kubernetes/kubernetes/blob/419e0ec3d2512afd8c1f35a44862f856bc4ac10f/pkg/scheduler/framework/plugins/noderesources/fit.go#L91, so I import it in the code:
import "k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources"
and use it just like:
s, ok := c.(*noderesources.preFilterState)
However I get an error: undefined: noderesources.preFilterState
I am not familiar with Kubernetes, so I don't know what is wrong with it. Thanks for your patience.
I try to print noderesources.Name but it failed too.
According to the link you're providing, preFilterState is not exported and therefore not accessible from the outside of the package.
It has nothing to do with Kubernetes but with go:
example: https://go.dev/tour/basics/3
doc: https://go.dev/doc/effective_go#names
I have a feeling you are starting with go, I recommend you play a bit with the fundamentals of the language and maybe use an IDE/Text editor with intellisense to be able to know what you can and cannot call.

Passing code from CodePipeline to PythonFunction

I'm trying to create a CDK app that will deploy a pipeline-stack and a lambda-stack. Similar to the tutorial here. I'm trying to implement a basic CI/CD application that is triggered with every push to a Github Enterprise Repo.
I chose to use PythonFunction from (#aws-cdk/aws-lambda-python) instead of function from #aws-cdk/aws-lambda because PythonFunction builds the dependencies from requirements.txt. I have various lambdas that use different packages (like awswrangler, pandas, requests, etc.).
But, PythonFunction does not support CfnParametersCode (Where the code is passed through CDK instead of being read from an asset).
What other option do I have to pass my code from GithubEnterprise to
the PythonFunction?
If function from #aws-cdk/aws-lambda is the only option I have, how
can I include the packages from requirements.txt
This does seem like an option for #aws-cdl/aws-lambda, but how would I pass my code from Github? This example relates to building from asset code.
I apologize if I'm missing something obvious, I just started working with AWS CDK last week.
First of all I would recommend to take a look at pipelines.CdkPipeline which is able to deal with Assets. That means you can directly use lambda.Code.from_asset instead of overriding CfnParametersCode in the Pipeline.
Regarding your other question, you can deal with the requirements by installing them into your lambda folder during the build step with: pip install -r requirements.txt -t .
CfnParametersCode gives you the ability to upload your code from an S3 file.
You can do the same via lambda.Code.fromBucket.
Taking your link from the third point (https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda#bundling-asset-code) You just need to use lambda.Code.fromBucket instead of code: lambda.Code.fromAsset. Docs can be found here: https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda

Checking a remote url depending upon config

I am a new NativeScript user and I am trying to understand how to have my app make a GET call to a remote server, depending upon environment. In Java world we pass in an environment variable, but I have not found an example (that I understand) demonstrating how my NativeScript mobile app will know which environment it is running in, and how to get values based upon that.
I am presuming that I will have a config/ with files such as
prod.conf.js and dev.conf.js - and there is where I will put in my urls and other config values.
How do I get my NativeScript (which I will eventually build into iOS) to reach those values to use in an http request upon startup. Any example to direction to documentation would be greatly appreciated.
Answer:
I finally got the problem solved by using Manoj suggestion of nativescript-dev-appconfig. For any newbie looking for help, try this:
{PROJECT_ROOT}/config - create the environment files as {env}.json. These files are just json, with name-value pairs of the values you want. In may case that is
When you do your build: tns build ios --bundle --env.config {dev | test | prod }
This will take the contents of the selected env.config file (ie -env.config dev and copy it as - {PROJECT_ROOT}/app/config.json .
To use it within your code,
import config from "../config.json";
axios.get(config.MY_URL).then(result => {...}
Unfortunately using environment based config files are not officially supported but there is a plugin hook you could try.
We also have webpack based environment variable support, read more about that in the docs.

Laravel mailChimp package error

I try to use the package https://github.com/BlueBayTravel/Mailchimp as in examples but i got an error:
ErrorException in Mailchimp.php line 64:
Undefined property: BlueBayTravel\Mailchimp\Facades\Mailchimp::$users
when i try to use: Mailchimp::users(), while i can get a connection via Mailchimp::getDefaultConnection(); mean the package is completely red, what u guess the problem with me here ?
I saw that you already opened an issue in the package repo.
If you are using Laravel, and you want to use an existing integration with Mailchimp, I would recommend you to give a try to the spatie/laravel-newsletter package. It's the most complete package I've found for the integration Laravel + Mailchimp, and it uses the drewm/mailchimp-api API wrapper (which IMO, is the best php wrapper for Mailchimp). You can find some examples at Freek's blog or at the README file of the project. And if you do not find what you need, you can go to a lower level using the drewm wrapper: $api = Newsletter::getApi();
If this is not what you are looking for, you can always create your own service in Laravel, adapted to your needs and requierements ;)

Griffon upgrade: dealing with startup arguments

I'm upgrading a big 0.3.1 Griffon app into 0.9.4 I'm getting these difficulties:
Startup arguments:
I needed to deal with startup arguments so there was (in previous version) a:
class MyApplication extends SwingApplication
now it seems this can be accomplished in a cleaner way using:
app.getStartupArgs()
where should I put my own code? in Initialize.groovy script perhaps?
Any post or example on how to deal with these arguments?
Thanks in advance.
Accessing app.getStartupArgs() can be done from anywhere you have access to the app variable. Remember that lifecycle scripts are always executed inside the EDT, no exceptions.
Personally I tend to use application events more and more, for example reading the startup args after all startup mvc groups have been created can be done like this (in a file named griffon-app/conf/Events.groovy)
onStartupEnd = { app ->
println app.startupArgs
}

Resources