首页 > 编程语言 >用Python调用OpenAI API做有趣的事

用Python调用OpenAI API做有趣的事

时间:2022-12-14 20:45:48浏览次数:70  
标签:container Python image access runner API OpenAI entrypoint Docker

Override the entrypoint of an image

Introduced in GitLab and GitLab Runner 9.4. Read more about the extended configuration options.

Before explaining the available entrypoint override methods, let’s describe how the runner starts. It uses a Docker image for the containers used in the CI/CD jobs:

  1. The runner starts a Docker container using the defined entrypoint. The default from Dockerfile that may be overridden in the .gitlab-ci.yml file.
  2. The runner attaches itself to a running container.
  3. The runner prepares a script (the combination of before_scriptscript, and after_script).
  4. The runner sends the script to the container’s shell stdin and receives the output.

To override the entrypoint of a Docker image, define an empty entrypoint in the .gitlab-ci.yml file, so the runner does not start a useless shell layer. However, that does not work for all Docker versions.

  • For Docker 17.06 and later, the entrypoint can be set to an empty value.
  • For Docker 17.03 and earlier, the entrypoint can be set to /bin/sh -c/bin/bash -c, or an equivalent shell available in the image.

The syntax of image:entrypoint is similar to Dockerfile’s ENTRYPOINT.

Let’s assume you have a super/sql:experimental image with a SQL database in it. You want to use it as a base image for your job because you want to execute some tests with this database binary. Let’s also assume that this image is configured with /usr/bin/super-sql run as an entrypoint. When the container starts without additional options, it runs the database’s process. The runner expects that the image has no entrypoint or that the entrypoint is prepared to start a shell command.

With the extended Docker configuration options, instead of:

  • Creating your own image based on super/sql:experimental.
  • Setting the ENTRYPOINT to a shell.
  • Using the new image in your CI job.

You can now define an entrypoint in the .gitlab-ci.yml file.

For Docker 17.06 and later:

image:
  name: super/sql:experimental
  entrypoint: [""]

For Docker 17.03 and earlier:

image:
  name: super/sql:experimental
  entrypoint: ["/bin/sh", "-c"]

Define image and services in config.toml

Look for the [runners.docker] section:

[runners.docker]
  image = "ruby:latest"
  services = ["mysql:latest", "postgres:latest"]

The image and services defined this way are added to all jobs run by that runner.

Access an image from a private Container Registry

To access private container registries, the GitLab Runner process can use:

To define which option should be used, the runner process reads the configuration in this order:

  • DOCKER_AUTH_CONFIG CI/CD variable.
  • DOCKER_AUTH_CONFIG environment variable set in the runner’s config.toml file.
  • config.json file in $HOME/.docker directory of the user running the process. If the --user flag is provided to run the child processes as unprivileged user, the home directory of the main runner process user is used.

Requirements and limitations

  • Available for Kubernetes executor in GitLab Runner 13.1 and later.
  • Credentials Store and Credential Helpers require binaries to be added to the GitLab Runner $PATH, and require access to do so. Therefore, these features are not available on shared runners, or any other runner where the user does not have access to the environment where the runner is installed.

Use statically-defined credentials

There are two approaches that you can take to access a private registry. Both require setting the CI/CD variable DOCKER_AUTH_CONFIG with appropriate authentication information.

  1. Per-job: To configure one job to access a private registry, add DOCKER_AUTH_CONFIG as a CI/CD variable.
  2. Per-runner: To configure a runner so all its jobs can access a private registry, add DOCKER_AUTH_CONFIG as an environment variable in the runner’s configuration.

标签:container,Python,image,access,runner,API,OpenAI,entrypoint,Docker
From: https://www.cnblogs.com/sdfasdf/p/16983461.html

相关文章

  • 仿真环境设置(一)- windows10, python 3.8
    1安装miniconda参考网上材料,打开Miniconda官网,点击对应系统版本的安装器,然后安装即可。安装过程中推荐:为所有人/只为我:只为我;将conda添加到PATH中,是/否:是。(虽然不......
  • Python笔记--字符串
    字符串的三种定义单引号定义法:双引号定义法:三引号定义法:结果:其中,三引号定义的话,不用变量接收的话,就相当于多行注释;用变量接收的话,就是对于字符串的定义了。字符串......
  • 【Python】 try except 还是 if else(EAFP 还是 LBYL 风格)
     结论● 若超过95%的可能不会进入except异常处理中,则使用代码一的样式(EAFP风格)● 否则可以换成用代码二的样式(LBYL风格) 代码一(EAFP风格):try:判断代码excep......
  • Python小球移动游戏
    #-*-coding:utf-8-*-importsys#导入sys模块importpygame#导入pygame模块pygame.init()#初始化pygamesize=width,height=640,480#设置窗口screen......
  • Python 12章 GUI
    GUI界面此处使用wxpython需要先pip库实例1importwxclassMyFrame(wx.Frame):def__init__(self,parent,id):wx.Frame.__init__(self,parent,id,tit......
  • Python实现从一个列表数据里随机抽取数据,并且按原有顺序排序
    背景:工作中需要实现从多个条件中随机抽取几个条件,进行组合查询的功能。而查询的结果需要按原顺序进行判断是否符合查询条件。分析:这些条件可以放在列表里,这就需要实现一个......
  • Python13 模块
    模块创建模块直接新建一个.py文件即可,这个py文件是可执行的哦~也是可以被导入的,这个py文件就是模块。导入模块import模块名[as别名]from模块名import函数/变......
  • Python第十一周
    一、实验目的和要求1、学会数据库编程接口;2、学会使用SQLite;3、学会使用MySQL。二、实验环境Python3.1064_bit三、实验过程实例一代码如下:1importsqlite3......
  • python实验报告(第8章)
    实例01:创建计算BMi指数的模块 创建一个用于根据身高、体重计算BMI指数的模块,命名为bmi.py,其中bmi为模块名,.py为扩展名。 代码如下:1deffun_bmi(pers......
  • Python实验报告(第9章)
    实例一:实验相关代码:defdivision():'''功能:分苹果'''print("\n==================分苹果了=================\n")apple=int(input("请输入苹......